c语言将图像转化为灰度图像,并将灰度图像像素值存入二维数组
1个回答
展开全部
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
int main(){
img = imread("./lena.png");
cvtColor(img, img, CV_BGR2GRAY);
uchar** pixmat = new uchar*[img.rows];
for(int i = 0; i < img.rows; i++){
pixmat[i] = new uchar[img.cols];
for(int j = 0; j < img.cols; j++){
pixmat[i][j] = img.at<uchar>(i, j);
}}}
//pixmat is demanded 2-D array
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
int main(){
img = imread("./lena.png");
cvtColor(img, img, CV_BGR2GRAY);
uchar** pixmat = new uchar*[img.rows];
for(int i = 0; i < img.rows; i++){
pixmat[i] = new uchar[img.cols];
for(int j = 0; j < img.cols; j++){
pixmat[i][j] = img.at<uchar>(i, j);
}}}
//pixmat is demanded 2-D array
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询