Reputation: 13
I get frame from avi video and I open color image by Matlab and check pixel value of three channel R,G,B. (case 1)
After that, I use opencv2.4.3 to get frame and save pixel value by txt file. Then, I check txt file, I realize pixel value is different from Matlab (I know color image opened by opencv is BGR, and the index position of pixel must be minus 1 (in Matlab, pixel position(x,y).In c,pixelposition (x-1,y-1))). (case 2)
Finally, I use opencv to save frame by cvSaveImage function and then I open this frame by Matlab. In this case, pixel value is also different from two above case.
Why this happens?
Thank you for answering! Sorry about my English!
This is my code http://www.scribd.com/doc/129263549/Code (you have to download it to read)
Upvotes: 1
Views: 1688
Reputation: 158
Matlab and OpenCV have different ways of storing pixel values. Matlab uses compression to save .jpeg images before storing them. So if you view the pixel data for similar images in Matlab and OpenCV, it will look different.
If you load and save the same source image in both Matlab and OpenCV, the former will be smaller in size than the later; even though you don't do any operations on the image.
There is no way you can make both image data to look same. Fortunately, any operations done on the image are not affected by this difference in the internal structure. For example, if you try to find the indices of certain pixels in Matlab and OpenCV, both will give correct values, though the values won't look the same.
Upvotes: 1