[android-developers] Re: Image comparison problem: getPixel() in android and getRGB() in JDK return different values for the same image
The problem was the JPG format. With PNG it works On 4 Feb., 01:42, gjs garyjamessi...@gmail.com wrote: Hi, Also maybe try .png format if possible. Regards On Feb 4, 8:21 am, Romain Guy romain...@android.com wrote: First make sure that both return values in the same format (Android returns ARGB not RGBA.) Also, f I remember correctly, Java2D can apply color profiles when loading a bitmap. On Feb 3, 2012 11:05 AM, Ergen andv...@googlemail.com wrote: Hi. I want to compare two images. One image is on the android client and another image is on the server (with Tomcat, JDK). I need also to calculate two histograms - one for each image - and to compare they The problem is: getPixel (x, y) (on Android) and getRGB (x, y) (JDK) return different rgb color numbers for the point with the same coordinates (x, y). The images are here identical (JPG, Size: 3x3). Why are the results different? And what to do? I've been looking for the answer everywhere, but... *** Pseudocode for Androids Activity *** BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPreferredConfig = Bitmap.Config.ARGB_; mBitmap = BitmapFactory.decodeFile(imageSource, opt); int intColor = 0; for (int x = 0; x mBitmap.getWidth(); x++) { for (int y = 0; y mBitmap.getHeight(); y++) { intColor = mBitmap.getPixel(x, y); System.out.print( (+ x + ,+ y +) c: + intColor); } }System.out.println(); Result for example image 3x3: (0,0)c:-7882802 (0,1)c:-9859138 (0,2)c:-6507579 (1,0)c:-12883825 (1,1)c:-6574388 (1,2)c:-7948604 (2,0)c:-7489593 (2,1)c:-10579009 (2,2)c:-6573359 Pseudocode for JDK BufferedImage img = ImageIO.read( file ); int intColor = 0; for ( int x = 0; x img.getWidth(); x++ ) { for ( int y = 0; y img.getHeight(); y++ ) { intColor = img.getRGB( x, y ); System.out.print( (+ x + ,+ y +) c: + intColor); } }System.out.println(); Result for the same image: (0,0)c:-7883056 (0,1)c:-9728065 (0,2)c:-6507579 (1,0)c:-12818030 (1,1)c:-6377523 (1,2)c:-7883323 (2,0)c:-7424055 (2,1)c:-10513470 (2,2)c:-6573358 -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Image comparison problem: getPixel() in android and getRGB() in JDK return different values for the same image
The problem was the JPG format. On 3 Feb., 22:21, Romain Guy romain...@android.com wrote: First make sure that both return values in the same format (Android returns ARGB not RGBA.) Also, f I remember correctly, Java2D can apply color profiles when loading a bitmap. On Feb 3, 2012 11:05 AM, Ergen andv...@googlemail.com wrote: Hi. I want to compare two images. One image is on the android client and another image is on the server (with Tomcat, JDK). I need also to calculate two histograms - one for each image - and to compare they The problem is: getPixel (x, y) (on Android) and getRGB (x, y) (JDK) return different rgb color numbers for the point with the same coordinates (x, y). The images are here identical (JPG, Size: 3x3). Why are the results different? And what to do? I've been looking for the answer everywhere, but... *** Pseudocode for Androids Activity *** BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPreferredConfig = Bitmap.Config.ARGB_; mBitmap = BitmapFactory.decodeFile(imageSource, opt); int intColor = 0; for (int x = 0; x mBitmap.getWidth(); x++) { for (int y = 0; y mBitmap.getHeight(); y++) { intColor = mBitmap.getPixel(x, y); System.out.print( (+ x + ,+ y +) c: + intColor); } }System.out.println(); Result for example image 3x3: (0,0)c:-7882802 (0,1)c:-9859138 (0,2)c:-6507579 (1,0)c:-12883825 (1,1)c:-6574388 (1,2)c:-7948604 (2,0)c:-7489593 (2,1)c:-10579009 (2,2)c:-6573359 Pseudocode for JDK BufferedImage img = ImageIO.read( file ); int intColor = 0; for ( int x = 0; x img.getWidth(); x++ ) { for ( int y = 0; y img.getHeight(); y++ ) { intColor = img.getRGB( x, y ); System.out.print( (+ x + ,+ y +) c: + intColor); } }System.out.println(); Result for the same image: (0,0)c:-7883056 (0,1)c:-9728065 (0,2)c:-6507579 (1,0)c:-12818030 (1,1)c:-6377523 (1,2)c:-7883323 (2,0)c:-7424055 (2,1)c:-10513470 (2,2)c:-6573358 -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Image comparison problem: getPixel() in android and getRGB() in JDK return different values for the same image
Thanks. I've thought about it. And I tried to change the format _after_ loading the image. I created a new image IMG2 with new BufferedImage(width, hight, IMAGE_TYPE) and copied old image (also IMG1) into the new image as IMG2.createGraphics().drawRenderedImage(IMG1,null) Then i've tested all the formats in Java2D (all constans of IMAGE_TYPE). All in vain. Also, f I remember correctly, Java2D can apply color profiles when loading a bitmap. That would be perfect. But I found no method to make it. I'll try it again in the evening... On 3 Feb., 22:21, Romain Guy romain...@android.com wrote: First make sure that both return values in the same format (Android returns ARGB not RGBA.) Also, f I remember correctly, Java2D can apply color profiles when loading a bitmap. On Feb 3, 2012 11:05 AM, Ergen andv...@googlemail.com wrote: Hi. I want to compare two images. One image is on the android client and another image is on the server (with Tomcat, JDK). I need also to calculate two histograms - one for each image - and to compare they The problem is: getPixel (x, y) (on Android) and getRGB (x, y) (JDK) return different rgb color numbers for the point with the same coordinates (x, y). The images are here identical (JPG, Size: 3x3). Why are the results different? And what to do? I've been looking for the answer everywhere, but... *** Pseudocode for Androids Activity *** BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPreferredConfig = Bitmap.Config.ARGB_; mBitmap = BitmapFactory.decodeFile(imageSource, opt); int intColor = 0; for (int x = 0; x mBitmap.getWidth(); x++) { for (int y = 0; y mBitmap.getHeight(); y++) { intColor = mBitmap.getPixel(x, y); System.out.print( (+ x + ,+ y +) c: + intColor); } }System.out.println(); Result for example image 3x3: (0,0)c:-7882802 (0,1)c:-9859138 (0,2)c:-6507579 (1,0)c:-12883825 (1,1)c:-6574388 (1,2)c:-7948604 (2,0)c:-7489593 (2,1)c:-10579009 (2,2)c:-6573359 Pseudocode for JDK BufferedImage img = ImageIO.read( file ); int intColor = 0; for ( int x = 0; x img.getWidth(); x++ ) { for ( int y = 0; y img.getHeight(); y++ ) { intColor = img.getRGB( x, y ); System.out.print( (+ x + ,+ y +) c: + intColor); } }System.out.println(); Result for the same image: (0,0)c:-7883056 (0,1)c:-9728065 (0,2)c:-6507579 (1,0)c:-12818030 (1,1)c:-6377523 (1,2)c:-7883323 (2,0)c:-7424055 (2,1)c:-10513470 (2,2)c:-6573358 -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Image comparison problem: getPixel() in android and getRGB() in JDK return different values for the same image
Thanks. I tried it once, but that changed nothing. I'll try it again. I need solve the problem somehow. :) On 4 Feb., 01:42, gjs garyjamessi...@gmail.com wrote: Hi, Also maybe try .png format if possible. Regards On Feb 4, 8:21 am, Romain Guy romain...@android.com wrote: First make sure that both return values in the same format (Android returns ARGB not RGBA.) Also, f I remember correctly, Java2D can apply color profiles when loading a bitmap. On Feb 3, 2012 11:05 AM, Ergen andv...@googlemail.com wrote: Hi. I want to compare two images. One image is on the android client and another image is on the server (with Tomcat, JDK). I need also to calculate two histograms - one for each image - and to compare they The problem is: getPixel (x, y) (on Android) and getRGB (x, y) (JDK) return different rgb color numbers for the point with the same coordinates (x, y). The images are here identical (JPG, Size: 3x3). Why are the results different? And what to do? I've been looking for the answer everywhere, but... *** Pseudocode for Androids Activity *** BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPreferredConfig = Bitmap.Config.ARGB_; mBitmap = BitmapFactory.decodeFile(imageSource, opt); int intColor = 0; for (int x = 0; x mBitmap.getWidth(); x++) { for (int y = 0; y mBitmap.getHeight(); y++) { intColor = mBitmap.getPixel(x, y); System.out.print( (+ x + ,+ y +) c: + intColor); } }System.out.println(); Result for example image 3x3: (0,0)c:-7882802 (0,1)c:-9859138 (0,2)c:-6507579 (1,0)c:-12883825 (1,1)c:-6574388 (1,2)c:-7948604 (2,0)c:-7489593 (2,1)c:-10579009 (2,2)c:-6573359 Pseudocode for JDK BufferedImage img = ImageIO.read( file ); int intColor = 0; for ( int x = 0; x img.getWidth(); x++ ) { for ( int y = 0; y img.getHeight(); y++ ) { intColor = img.getRGB( x, y ); System.out.print( (+ x + ,+ y +) c: + intColor); } }System.out.println(); Result for the same image: (0,0)c:-7883056 (0,1)c:-9728065 (0,2)c:-6507579 (1,0)c:-12818030 (1,1)c:-6377523 (1,2)c:-7883323 (2,0)c:-7424055 (2,1)c:-10513470 (2,2)c:-6573358 -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Image comparison problem: getPixel() in android and getRGB() in JDK return different values for the same image
Hi, Also maybe try .png format if possible. Regards On Feb 4, 8:21 am, Romain Guy romain...@android.com wrote: First make sure that both return values in the same format (Android returns ARGB not RGBA.) Also, f I remember correctly, Java2D can apply color profiles when loading a bitmap. On Feb 3, 2012 11:05 AM, Ergen andv...@googlemail.com wrote: Hi. I want to compare two images. One image is on the android client and another image is on the server (with Tomcat, JDK). I need also to calculate two histograms - one for each image - and to compare they The problem is: getPixel (x, y) (on Android) and getRGB (x, y) (JDK) return different rgb color numbers for the point with the same coordinates (x, y). The images are here identical (JPG, Size: 3x3). Why are the results different? And what to do? I've been looking for the answer everywhere, but... *** Pseudocode for Androids Activity *** BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPreferredConfig = Bitmap.Config.ARGB_; mBitmap = BitmapFactory.decodeFile(imageSource, opt); int intColor = 0; for (int x = 0; x mBitmap.getWidth(); x++) { for (int y = 0; y mBitmap.getHeight(); y++) { intColor = mBitmap.getPixel(x, y); System.out.print( (+ x + ,+ y +) c: + intColor); } }System.out.println(); Result for example image 3x3: (0,0)c:-7882802 (0,1)c:-9859138 (0,2)c:-6507579 (1,0)c:-12883825 (1,1)c:-6574388 (1,2)c:-7948604 (2,0)c:-7489593 (2,1)c:-10579009 (2,2)c:-6573359 Pseudocode for JDK BufferedImage img = ImageIO.read( file ); int intColor = 0; for ( int x = 0; x img.getWidth(); x++ ) { for ( int y = 0; y img.getHeight(); y++ ) { intColor = img.getRGB( x, y ); System.out.print( (+ x + ,+ y +) c: + intColor); } }System.out.println(); Result for the same image: (0,0)c:-7883056 (0,1)c:-9728065 (0,2)c:-6507579 (1,0)c:-12818030 (1,1)c:-6377523 (1,2)c:-7883323 (2,0)c:-7424055 (2,1)c:-10513470 (2,2)c:-6573358 -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en