What value is return when accessing a pixel from a colored image
Hello!
Im having some problems lately about getting the color of a pixel using Open CV and java .
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat a = Imgcodecs.imread("C:\\Users\\User\\workspace\\OpenCv\\color.png",Imgcodecs.CV_LOAD_IMAGE_COLOR);
System.out.println(Arrays.toString(getPixelColor(0, 0, a)));
System.out.println(Arrays.toString(getPixelColor(9, 0, a)));
System.out.println(Arrays.toString(getPixelColor(0, 9, a)));
System.out.println(Arrays.toString(getPixelColor(9, 9, a)));
So this code returns the following
[255.0, 255.0, 0.0]
[0.0, 0.0, 255.0]
[255.0, 0.0, 0.0]
[0.0, 255.0, 255.0]
for this image its a 10*10 image But the right rgb color from photoshop are int that order
[0, 255.0, 255.0] Cyan
[0.0, 0.0, 255.0] Blue
[255.0, 0.0, 0.0] Red
[255.0, 255.0, 0] Yellow
The image loads up as mat from type CV_8UC3 so its rbg.
Anyone knows why is this happening ? Also if im using cvtColor to change from bgr -> rbg im not getting the right output still
[0.0, 255.0, 255.0] Cyan ok
[255.0, 0.0, 0.0] Should be blue , is red
[0.0, 0.0, 255.0] Should be red , is blue
[255.0, 255.0, 0.0] Yellow ok
can it simply be, that your getPixelColor function gets x,y wrong ?