I use the OpenCV to manipulate images (RGB Color).I have a problem about the recovery of the value of all pixels in the image.
value of a pixel in a given position
Code:
i = 0, / / line 0
j = 0, / / column 0
img = cvLoadImage ( "1.jpg", 1);
pixel = cvGet2D (img, i, j) / / read pixel column 25 line 10
/ / pixel = cvGet2D (img, 1,1);
printf ( "value of the pixel blue:% f \ n", pixel.val [0]) / / blue value of pixel
printf ( "pixel green value:% f \ n", pixel.val [1]) / / blue value of pixel
printf ( "value of the pixel red:% f \ n", pixel.val [2]) / / blue value of pixel
at this level, I'd like to know if the value of the pixel at position (0.0) is image1 pixel.val [0] + pixel.val [1] + pixel.val [2]
the value of each pixel in the image
to retrieve all the pixels of the image as a matrix I done this:
Code:
for (i = 0; i <height; i + +) (
for (j = 0 j <width; j + +) (
pixel = cvGet2D (img, i, j);
/ / printf ( "value of the pixel blue:% f \ n", pixel.val [0]);
som2 = pixel.val [0] + pixel.val [1] + pixel.val [2];
/ / fprintf (fic_image, "% f% f% F", pixel.val [0], pixel.val [1], pixel.val [2]);
)
)
I see image 1 is different from image 2.
Thank you in advance!
Bookmarks