-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
jdk1.5.0_08
ADDITIONAL OS VERSION INFORMATION :
SuSE Linux 10.0
Windows XP SP2
A DESCRIPTION OF THE PROBLEM :
The method getRGB(x,y) from the BufferedImage class doesn´t returns the real pixel value of a grayscale image in bitmap format. If the real pixel value at (173,179) position of a bitmp grayscale image is "39" the result after the operation getRGB(173,179) & 0xff is "109" or using the class Color to get the Red, Green and Blue values it returns the same results as above. Example: Color.getRed()=109, g=109, b=109, while the correct results should be r=39, g=39, b=39. This difference in the results happens in any selected position.
These "real pixel values" were obtained from the softwares ACDSee, Gimp, Matlab and AdobePhotoshop.
This error occurs in Windows and Linux as well (the operating systems I´ve tested).
Even if someone tries to get the pixel value from PixelGraber class the result is the same, the error persists.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
For example:
// load a grayscale image
BufferedImage bi = ImageIO.read(new File("/image/Frame#1.bmp"));
//select a specific point of the image to collect the pixel value. Ex. (173,179)
Color c = new Color ( bi.getRGB(173,179));
// print the result on the screen . It may be the Red, green or blue value
// because in grayscale images R=G=B. At this time the printed result must be
// the same as the results from the other softwares.
System.out.println("Pixel value in position (173,179): " + c.getBlue());
// unfortunatelly it doesn´t happen. The image from which I´ve been trying to
// get the pixel values is the same used in Gimp, Adobe Photoshop, Matlab
// (6.1 or 7.0) and ACDSee.
==> Result
=> Pixel value in position (173,179): 109
==> Should be 39.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected result is the real value of that pixel selected by that specified position.
ACTUAL -
The actul result is far away from the correct one;
Ex: Position (173,179) = 109 => should be 39;
Position(173,155) = 141 => should be 98;
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
BufferedImage img = ImageIO.read(new File("c:\\24104604\\Frame#1.bmp"));
AffineTransform at = new AffineTransform();
int size[] = {232, 163};
double rad = Math.toRadians(1);
at.rotate(rad,size[0], size[1]);
at.translate(5,0);
AffineTransformOp atop = new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
img = atop.filter(img,null);
BufferedImage temp = new BufferedImage(464,325, BufferedImage.TYPE_BYTE_GRAY);
temp.createGraphics().drawImage(img, null, 0,0);
Color c = new Color(temp.getRGB(173,179));
ImageIO.write(temp,"bmp",new File("C:\\24104604\\AlignedFrame#11.bmp"));
Integer pixel = temp.getRGB(173,179);
byte by = pixel.byteValue();
System.out.println("Byte value: " + by);
BufferedImage bi = ImageIO.read(new File("c:\\24104604\\Frame#1.bmp"));
Color c2 = new Color (bi.getRGB(173,179));
float pixel2 = c2.getBlue();
System.err.println("Pixel value in position (173,179) from the aligned frame: " + pixel + "; and from original frame: " + pixel2);
// the results should be 40 and 39 but htey are 110 and 109.
---------- END SOURCE ----------
jdk1.5.0_08
ADDITIONAL OS VERSION INFORMATION :
SuSE Linux 10.0
Windows XP SP2
A DESCRIPTION OF THE PROBLEM :
The method getRGB(x,y) from the BufferedImage class doesn´t returns the real pixel value of a grayscale image in bitmap format. If the real pixel value at (173,179) position of a bitmp grayscale image is "39" the result after the operation getRGB(173,179) & 0xff is "109" or using the class Color to get the Red, Green and Blue values it returns the same results as above. Example: Color.getRed()=109, g=109, b=109, while the correct results should be r=39, g=39, b=39. This difference in the results happens in any selected position.
These "real pixel values" were obtained from the softwares ACDSee, Gimp, Matlab and AdobePhotoshop.
This error occurs in Windows and Linux as well (the operating systems I´ve tested).
Even if someone tries to get the pixel value from PixelGraber class the result is the same, the error persists.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
For example:
// load a grayscale image
BufferedImage bi = ImageIO.read(new File("/image/Frame#1.bmp"));
//select a specific point of the image to collect the pixel value. Ex. (173,179)
Color c = new Color ( bi.getRGB(173,179));
// print the result on the screen . It may be the Red, green or blue value
// because in grayscale images R=G=B. At this time the printed result must be
// the same as the results from the other softwares.
System.out.println("Pixel value in position (173,179): " + c.getBlue());
// unfortunatelly it doesn´t happen. The image from which I´ve been trying to
// get the pixel values is the same used in Gimp, Adobe Photoshop, Matlab
// (6.1 or 7.0) and ACDSee.
==> Result
=> Pixel value in position (173,179): 109
==> Should be 39.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected result is the real value of that pixel selected by that specified position.
ACTUAL -
The actul result is far away from the correct one;
Ex: Position (173,179) = 109 => should be 39;
Position(173,155) = 141 => should be 98;
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
BufferedImage img = ImageIO.read(new File("c:\\24104604\\Frame#1.bmp"));
AffineTransform at = new AffineTransform();
int size[] = {232, 163};
double rad = Math.toRadians(1);
at.rotate(rad,size[0], size[1]);
at.translate(5,0);
AffineTransformOp atop = new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
img = atop.filter(img,null);
BufferedImage temp = new BufferedImage(464,325, BufferedImage.TYPE_BYTE_GRAY);
temp.createGraphics().drawImage(img, null, 0,0);
Color c = new Color(temp.getRGB(173,179));
ImageIO.write(temp,"bmp",new File("C:\\24104604\\AlignedFrame#11.bmp"));
Integer pixel = temp.getRGB(173,179);
byte by = pixel.byteValue();
System.out.println("Byte value: " + by);
BufferedImage bi = ImageIO.read(new File("c:\\24104604\\Frame#1.bmp"));
Color c2 = new Color (bi.getRGB(173,179));
float pixel2 = c2.getBlue();
System.err.println("Pixel value in position (173,179) from the aligned frame: " + pixel + "; and from original frame: " + pixel2);
// the results should be 40 and 39 but htey are 110 and 109.
---------- END SOURCE ----------
- duplicates
-
JDK-5051418 Grayscale TYPE_CUSTOM BufferedImages are rendered lighter than TYPE_BYTE_GRAY
-
- Closed
-