A
aaaaaaaaaaaa
Hello
How to create "black&white" image?
First BufferedImage:
BufferedImage bImage = new BufferedImage(imageWidth,
imageHeight,BufferedImage.TYPE_BYTE_GRAY);
And then my code is:
for (int x = 0; x < imageWidth; x++)
for (int y = 0; y < imageHeight; y++) {
int pix = 0xff;
pix = (pix << 8) | Y[x][y];
pix = (pix << 8) | Y[x][y];
pix = (pix << 8) | Y[x][y];
bImage.setRGB(x, y, pix);
}
or:
int i = 0;
int[] tabColor = new int[256];
for (i = 0; i < 256; i++)
tabColor = (new Color(i, i, i)).getRGB();
for (int x = 0; x < imageWidth; x++)
for (int y = 0; y < imageHeight; y++)
bImage.setRGB(x, y, tabColor[Y[x][y]]);
Y[x][y] - integer values from 0 to 255.
Both metods does the same effect. Bad effect.
They create b&w image, but with terrible contrast - image is very dark.
What's wrong?
My only idea is stretching histogram to improve contrast
How to create "black&white" image?
First BufferedImage:
BufferedImage bImage = new BufferedImage(imageWidth,
imageHeight,BufferedImage.TYPE_BYTE_GRAY);
And then my code is:
for (int x = 0; x < imageWidth; x++)
for (int y = 0; y < imageHeight; y++) {
int pix = 0xff;
pix = (pix << 8) | Y[x][y];
pix = (pix << 8) | Y[x][y];
pix = (pix << 8) | Y[x][y];
bImage.setRGB(x, y, pix);
}
or:
int i = 0;
int[] tabColor = new int[256];
for (i = 0; i < 256; i++)
tabColor = (new Color(i, i, i)).getRGB();
for (int x = 0; x < imageWidth; x++)
for (int y = 0; y < imageHeight; y++)
bImage.setRGB(x, y, tabColor[Y[x][y]]);
Y[x][y] - integer values from 0 to 255.
Both metods does the same effect. Bad effect.
They create b&w image, but with terrible contrast - image is very dark.
What's wrong?
My only idea is stretching histogram to improve contrast