0

I'm currently converting a code that I've done in JAVA into C++ that uses some machine learning algorithm. The problem is that some pixel values are different if I load the image under java with respect to loading them in C++ (OpenCV). The JAVA code is:

BufferedImage img = ImageIO.read(new java.io.FileInputStream("lena.jpg"));

The C++ code is:

IplImage *img = cvLoadImage("lena.jpg", CV_LOAD_IMAGE_COLOR );

When I try to compare the pixel values I obtain differences like:

IplImage

169 72 83 
174 70 79 
183 72 81 
188 74 82 

BufferedImage

170 63 73
175 65 74
183 72 79
188 74 82

As you can see the values are similar, but not the same and this causes some problems in the machine learning algorithm. Did someone had the same issues?

1 Answers1

0

The Jpeg decoder library implementation might be different. Not a big issue.

Krish
  • 1,747
  • 14
  • 19
  • Sorry. The problem is in my code. cvGet2d(img,x,y) return a different pixel. The solution is simply use cvGet2d(img,y,x) (x for wigth, y for height) in for cicle. – user1735256 Oct 12 '12 at 11:34