Results 1 to 2 of 2
  1. #1
    sarah49 is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default green channel extraction

    i'm trying to mask non-green and alpha channels from images. The following code worked for single image but when i tried working for multiple images i get a black image as output, instead of green. Can anyone help me?


    Java Code:
    public class green 
    {
      private Vector<Integer> w = null;
      private Vector<Integer> h = null;
      private int pixelCol;
      private BufferedImage[] g=null;
      public BufferedImage[] MaskNongreen(BufferedImage bi[]) // input images array
      {
        w = new Vector<Integer>();
        h = new Vector<Integer>();
        g=new BufferedImage[bi.length];
     
        for(int i=0;i<bi.length;i++)
        { 
           w.add(bi[i].getWidth());
           h.add(bi[i].getHeight());
           g[i]=new BufferedImage(w.get(i),h.get(i),bi[i].getType());
         
           for (int x=0; x < w.size(); x++)
           {
           for (int y = 0; y <h.size(); y++)
           {     
            pixelCol=bi[i].getRGB(x,y);      
            pixelCol &= 0x0FF00FF00; //masks nongreen and alpha
            g[i].setRGB(x, y, pixelCol);
           }
          }
        }
       return g;
      }
     }

  2. #2
    sarah49 is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default Re: green channel extraction

    made a silly mistake in for loop.It works fine now

Similar Threads

  1. 10 green bottles
    By Dave013 in forum New To Java
    Replies: 2
    Last Post: 10-25-2011, 06:41 PM
  2. Why do I get this green text?
    By thestubbsinator in forum New To Java
    Replies: 5
    Last Post: 06-07-2010, 12:04 PM
  3. [SOLVED] Expected Range: Red Green Blue
    By AndrewM16921 in forum New To Java
    Replies: 1
    Last Post: 04-03-2009, 07:59 PM
  4. Need Support for Using Network service providers channel to carry speech
    By Nagasubramanian in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 02-13-2009, 12:10 PM
  5. Help with Java IRC Chat Channel
    By sari in forum New To Java
    Replies: 1
    Last Post: 02-03-2009, 07:21 AM

Tags for this Thread

Posting Permissions

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