output image is not displayed
Posted
by
gerry chocolatos
on Stack Overflow
See other posts from Stack Overflow
or by gerry chocolatos
Published on 2011-01-07T06:12:55Z
Indexed on
2011/01/08
14:54 UTC
Read the original article
Hit count: 192
so, im doing an image detection which i have to process on each red, green, n blue element to get the edge map and combine them become one to show the output. but it doesnt show my output image would anyone pls be kind enough to help me? here is my code so far.
//get the red element
process_red = new int[width * height];
counter = 0;
for(int i = 0; i < 256; i++) {
for(int j = 0; j < 256; j++) {
int clr = buff_red.getRGB(j, i);
int red = (clr & 0x00ff0000) >> 16;
red = (0xFF<<24)|(red<<16)|(red<<8)|red;
process_red[counter] = red;
counter++;
}
}
//set threshold value for red element
int threshold = 100;
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int bin = (buff_red.getRGB(x, y) & 0x000000ff);
if (bin < threshold)
bin = 0;
else
bin = 255;
buff_red.setRGB(x,y, 0xff000000 | bin << 16 | bin << 8 | bin);
}
}
and i do the same way for my green n blue elements. and then i wanted to get to combination of the three by doing it this way:
//combine the three elements
process_combine = new int[width * height];
counter = 0;
for(int i = 0; i < 256; i++) {
for(int j = 0; j < 256; j++) {
int clr_a = buff_red.getRGB(j, i);
int ar = clr_a & 0x000000ff;
int clr_b = buff_green.getRGB(j, i);
int bg = clr_b & 0x000000ff;
int clr_c = buff_blue.getRGB(j, i);
int cb = clr_b & 0x000000ff;
int alpha = 0xff000000;
int combine = alpha|(ar<<16)|(bg<<8)|cb;
process_combine[counter] = combine;
counter++;
}
}
buff_rgb = new BufferedImage(width,height, BufferedImage.TYPE_INT_ARGB);
Graphics rgb;
rgb = buff_rgb.getGraphics();
rgb.drawImage(output_rgb, 0, 0, null);
rgb.dispose();
repaint();
and to show the output whic is from the combining process, i use a draw method:
g.drawImage(buff_rgb,800,100,this);
but still it doesnt show the image. can anyone pls help me? ur help is really appreciated. thanks.
© Stack Overflow or respective owner