# Pixel capture

• 11-16-2009, 08:54 PM
Maiquelnet
Pixel capture
Hello, I wrote an algorithm pixel neighborhood to capture a pixel of a particular value, and whether it has other connected to it (neighbors). If so, and if a number greater than 2, I want to modify the value of these pixels. It is a line (black) who had another (new line) connected to it ... The background is white, the image is in grayscale (). But the code in java is not working.
Code:

```raster = imagem.getRaster();        int cores[] = new int[255];    int count=0;      for (int x = 0; x < imagem.getWidth(); x++) {            for (int y = 0; y < imagem.getHeight(); y++) {                raster.getPixel(x, y, cores); // captura da combinação de cor do pixel                if ((cores[x,y]>=0) && (cores[x,y]<5)) {                if (cores[x-1]<5) count++;                        if (cores[x+1]<5) count++;                if (cores[y-1]<5) count++;                if (cores[y+1]<5) count++;                if ((cores[y-1]<5) && (cores[x-1]<5)) count++;                if ((cores[y-1]<5) && (cores[x+1]<5)) count++;                if ((cores[y+1]<5) && (cores[x-1]<5)) count++;                if ((cores[y+1]<5) && (cores[x+1]<5)) count++;                                }            if (count >=3) {                  //Aqui vai o código para trocar o valor destes pixels, mas falta eu bolar ainda...            }                      count=0;                                }        }```
In line 07 giving this error ...
This line should indicate that the pixel value out of this enter the condition (if) to calculate the pixels in the neighborhood ...
suggestions?
• 11-16-2009, 09:28 PM
mrmatt1111
Code:

`if ((cores[x,y]>=0) && (cores[x,y]<5)) {`

"x,y" is not valid syntax.