cv::Mat src_rgba;
std::cout << "w: " << src_rgba.cols
<< "h: " << src_rgba.rows
<< "c: " << src_rgba.channels()
<< std::endl;
cv::Mat img(INPUT_H, INPUT_W, CV_32F); //有参构造
cv::Mat img; //无参构造
cv::Mat img = cv::imread("XXX.jpg"); //读图
(1)img/255-0
cv::Mat one;
img.convertTo(one, CV_32F, 1.0/255, 0);
(4)拆分
cv::Mat img = cv::imread(argv[2]);
//2.拆分图片
cv::Mat img_channels[3];
split(img, img_channels);
//3.区域图片混合
cv::Mat img_blue = img_channels[0];
cv::Mat img_gree = img_channels[1];
cv::Mat img_red = img_channels[2];
cv::Mat one_img_blue;
cv::Mat one_img_gree;
cv::Mat one_img_red;
img_blue.convertTo(one_img_blue, CV_32F, 1.0/58.395, -2.118);
img_gree.convertTo(one_img_gree, CV_32F, 1.0/57.12, -2.036);
img_red.convertTo(one_img_red, CV_32F, 1.0/57.375, -1.804);
img_channels[0] = one_img_blue;
img_channels[1] = one_img_gree;
img_channels[2] = one_img_red;
//4.图片组合
cv::Mat img_merge;
merge(img_channels, 3, img_merge);
(3)求范数
【详情】
void cv::normalize(InputArry src,
InputOutputArray dst,
double alpha=1,
double beta=0,
int norm_type=NORM_L2,
int dtype=-1,
InputArray mark=noArry())
void showMat(cv::Mat &img){
std::cout << "图像元素查看 : " << img.rows<<"," << img.cols <(i, j)[0]<< ", " <<
(float)img.at(i, j)[1]<< ", " <<
(float)img.at(i, j)[2]<< ") " << std::endl;
//(int)img.at(i, j)[0]<< ", " <<
//(int)img.at(i, j)[1]<< ", " <<
//(int)img.at(i, j)[2]<< ") " << std::endl;
}
}
}
}
5-图像缩放
6-图像裁剪