Results 1 to 2 of 2

Thread: Pixel capture

  1. #1
    Maiquelnet is offline Member
    Join Date
    Nov 2009
    Rep Power

    Default 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.
    Java 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...    
    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 ...

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    San Jose, CA, USA
    Rep Power


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

    "x,y" is not valid syntax.
    My Hobby Project: LegacyClone

Similar Threads

  1. Scanning Image Pixel by Pixel
    By the_transltr in forum Advanced Java
    Replies: 5
    Last Post: 08-28-2012, 05:01 PM
  2. how to capture jsf form data
    By Srikala in forum JavaServer Faces (JSF)
    Replies: 2
    Last Post: 07-16-2009, 10:06 AM
  3. How to capture a widget image with a GC
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-02-2008, 09:00 PM
  4. How to capture IP packets
    By Hasan in forum Networking
    Replies: 1
    Last Post: 05-31-2007, 06:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts