1. cv::Mat 的属性
cv::Mat img ;
img = cv::imread( img_path, CV_LOAD_IMAGE_COLOR ) ;
if ( !img.data )
std::cout << "Could not open or find file " << img_path << std::endl ;
int img_rows = img.rows ; Mat 的高宽属性
int img_cols = img.cols ;
for( int h; h<img_rows; h++)
for( int w; w<img_cols; w++ )
{
img.at<uchar>(h, w ) ; note the order of the height and cols
} similar as that of matlab.
cv::Mat img( height, width, CV_8UC1, cv::Scalar(0) ) ;
------------------------------------------------------------------------------------
cv::Rect roi ;
roi.x = 0 ; start index of width
roi.y = 0 ; start index of height
roi.width = (int) img_cols/2 ;
roi.height = (int) img_rows/2 ;
cv::Mat crop_img ;
img(roi).copyTo(crop_img) ; 切取图像块
-----------------------------------------------------------------------------------
int crop_size_w = (int) img_cols/4 ;
int crop_size_h = (int)img_rows/4 ;
cv::Size inputSize( crop_size_w, crop_size_h ) ; note the order ???
cv::resize( crop_img, crop_img, inputSize, 0, 0, cv::INTER_LINEAR ) ;
resize image. ( src, dst, dst.size(), ... )
/// resize(src, dst, dst.size(), 0, 0, interpolation);
---------------------------------------------------------------------------------
int do_mirror = 1 ;
if( do_mirror )
cv::flip( crop_img, crop_img, 1 ) ; / 图像镜像
--------------------------------------------------------------------------------
---以上内容为个人观点,仅供参考。