Pixel Intensity in opencv#
I am a beginner in both Image Processing and Opencv. I am trying to find out the individual pixel intensities of an image, using OPENCV#. There is assistance here: http://docs.opencv.org/doc/user_guide/ug_mat.html?highlight=pixel%20intensity for the same issue. But I am not sure how to use it in OPENCV#. I know this is a very basic query. Please try to help out. Thanks in advance.
in emgu cv, you can do it like this.
//Color
//Red
byte Red_val = My_Image.Data[y,x,0];
//Green
byte Green_val = My_Image.Data[y,x,1];
//Blue
byte Blue_val = My_Image.Data[y,x,2];
//Greyscale
byte Gray_val = My_Image.Data[y,x,0];
Pixel intensity is the same thing as that pixel's grayscale value. To get a grayscale (pixel intensity) version of an RGB image you can do this:
cv::cvtColor(rgb_mat,gray_mat,CV_RGB2GRAY);
Now the 3 channel RGB image has been converted to a 1 channel GRAYSCALE image. To find the intensity of pixel (x,y) in the RGB image you can do this:
//NOTE: in OpenCV pixels are accessed in (row,col) format
int intensity = (int)gray_mat.at<uchar>(y,x);
Since each grayscale pixel is stored as uchar, the value of intensity
will range from (0-255) where 255 is maximum intensity (seen as a completely white pixel).
上一篇: 像素强度在百分比图中的分布
下一篇: 像素强度在opencv#