Reading pixel color from Image?

Hello frnds,
I am making a project in which i have to upload Image, am trying to find color of each pixel in RGB format so that I can locate where my sprite begins in Image !!
But I am not able to do so.. do I have to use PixelGrabber to do that? or should i use RGBImageFilter..!! I am new to java so if u can tell me how to use them, then It would be grateful.
I want to scan whole image from left to right, Right to left, top to bottom and vice-versa. So that I can exactly tell at what pixel value sprite starts and ends.
Please help me out. any sort of help will be useful for my project..
Thanking you in advance.

Image bufferImage;PixelGrabber pg1;
public boolean fetchPixels(byte[] jpegData, int[] pixelData)
     try
          bufferImage = Toolkit.getDefaultToolkit().createImage(jpegData);
          // this may not be required unless asynchronous, but seems to do no harm
          MediaTracker mt = new MediaTracker(jcamData);
          mt.addImage(bufferImage, 0);
          try
               mt.waitForID(0);
          catch(InterruptedException e)
               e.printStackTrace();
          if(mt.isErrorAny()==true)
               System.out.println("Exception fetchPixels "+"createImage failed");
               // flush anything in bufferedImage
               if(bufferImage!=null)bufferImage.flush();
               return false;     // and pixelData not updated
          Thread.yield();
          pg1 = new PixelGrabber(bufferImage, 0, 0, camWidth, camHeight, pixelData, 0, camWidth);
          try{pg1.grabPixels();}catch(InterruptedException e){}
          Thread.yield();
          // flush bufferedImage as no longer needed, and so not to be in memory cache for next image load
          if(bufferImage!=null)
               bufferImage.flush();               
     catch(Exception e){System.out.println("Exception fetchPixels "+e);}
     return true;
}

Similar Messages

  • How to get max 5 color from image??

    I try to get max 5 color from image (ex. jpeg,gif) ,I use PixelGrabber
    it too slowly when i use large image,Please help me, to run more fast
    (other way PixelGrabber)
    best regard
    [email protected],[email protected]
    source below:
    public String generateColor(InputStream source,String filePath){
    BufferedImage image = null;
    String RGB = "";
    System.out.println("==generateColor==");
    try {
    image = ImageIO.read(source);
    catch (IOException ex1) {
    ex1.printStackTrace();
    //image.getGraphics().getColor().get
    // BufferedImage image2 = ImageIO.read(source);
    // image.getColorModel().getNumColorComponents()
    if(image.getColorModel() instanceof IndexColorModel) {
    IndexColorModel icm = (IndexColorModel)image.getColorModel();
    byte[][] data = new byte[3][icm.getMapSize()];
    int[] rgbB = new int[icm.getMapSize()];
    icm.getRGBs(rgbB);
    String dataHtm = "<HTML><table width=\"100\" border=\"0\"><tr>";
    for(int i = 0 ;i< rgbB.length;i++){
    int r = (rgbB[i] >> 16) & 0xff;
    int g = (rgbB[i] >> 8) & 0xff;
    int k = (rgbB) & 0xff;
    System.out.println("red:" + Integer.toHexString(r));
    System.out.println("green:" + Integer.toHexString(g));
    System.out.println("blue:" + Integer.toHexString(k));
    dataHtm = dataHtm + "<td width=\"10\" bgcolor=\"#" + Integer.toHexString(r)+Integer.toHexString(g)+Integer.toHexString(k);
    dataHtm = dataHtm + "\"> </td>";
    dataHtm = dataHtm + "</tr></table></HTML>";
    try {
    BufferedWriter out = new BufferedWriter(new FileWriter("c:\\23289207.html"));
    out.write(dataHtm);
    out.close();
    catch (IOException e) {
    e.printStackTrace();
    int w = image.getWidth();
    int h = image.getHeight();
    int[] pixels = new int[w*h];
    int[] pixs = new int[w*h];
    System.out.println("image width:"+w+"image hight:"+h+"image w*h:"+(w*h));
    Image img = Toolkit.getDefaultToolkit().getImage(filePath);
    PixelGrabber pg = new PixelGrabber(img, 0,0, w, h, pixels, 0, w);
    try {
    pg.grabPixels();
    catch (Exception x) {
    x.printStackTrace();
    String picColor = "";
    Stack stackColor = new Stack();
    Hashtable hashColor = new Hashtable();
    for (int i = 0; i < w * h; i++) {
    int rgb = pixels[i];
    int a = (rgb >> 24) & 0xff;
    int r = (rgb >> 16) & 0xff;
    int g = (rgb >> 8) & 0xff;
    int k = (rgb) & 0xff;
    i = i+1000;
    //System.out.println("i:" + i);
    picColor = convertToSring(r)+convertToSring(g)+convertToSring(k);
    stackColor.add(picColor);
    //System.out.println("picColor:"+picColor);
    // System.out.println("\n\n a:" + a);
    // System.out.println("red:" + r);
    // System.out.println("green:" + g);
    // System.out.println("blue:" + k);
    }//end for
    getMaxColor(stackColor);
    System.out.println("==generateColor==end\n\n");
    return null;

    import java.awt.Color;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    public class HighFive
        private void examineColors(BufferedImage image)
            long start = System.currentTimeMillis();
            int w = image.getWidth(), h = image.getHeight();
            int[] rgbs = image.getRGB(0,0,w,h,null,0,w);
            findHighFive(rgbs);
            long end = System.currentTimeMillis();
            System.out.println("total time = " + (end - start)/1000.0 + " seconds");
        private void findHighFive(int[] colors)
            int[] uniqueColors = getUniqueColors(colors);
            int[] colorCounts  = getColorCounts(uniqueColors, colors);
            int[] highFive     = getHighFive(colorCounts);
            // for each value of highFive find index in colorCounts
            // and use this index to find color code in uniqueColors
            for(int j = 0; j < highFive.length; j++)
                int index = findIndexInArray(colorCounts, highFive[j]);
                Color color = new Color(uniqueColors[index]);
                String s = color.toString();
                s = s.substring(s.indexOf("["));
                System.out.println("color " + s + "  occurs " +
                                    highFive[j] + " times");
        private int[] getUniqueColors(int[] colors)
            // collect unique colors
            int[] uniqueColors = new int[colors.length];
            int count = 0;
            for(int j = 0; j < colors.length; j++)
                if(isUnique(uniqueColors, colors[j]))
                    uniqueColors[count++] = colors[j];
            // trim uniqueColors
            int[] temp = new int[count];
            System.arraycopy(uniqueColors, 0, temp, 0, count);
            uniqueColors = temp;
            return uniqueColors;
        private int[] getColorCounts(int[] uniqueColors, int[] colors)
            // count the occurance of each unique color in colors
            int[] colorCounts = new int[uniqueColors.length];
            for(int j = 0; j < colors.length; j++)
                int index = findIndexInArray(uniqueColors, colors[j]);
                colorCounts[index]++;
            return colorCounts;
        private int[] getHighFive(int[] colorCounts)
            // find five highest values in colorCounts
            int[] highFive = new int[5];
            int count = 0;
            for(int j = 0; j < highFive.length; j++)
                int max = Integer.MIN_VALUE;
                for(int k = 0; k < colorCounts.length; k++)
                    if(colorCounts[k] > max)
                        if(isUnique(highFive, colorCounts[k]))
                            max = colorCounts[k];
                            highFive[count] = colorCounts[k];
                count++;
            return highFive;
        private boolean isUnique(int[] n, int target)
            for(int j = 0; j < n.length; j++)
                if(n[j] == target)
                    return false;
            return true;
        private int findIndexInArray(int[] n, int target)
            for(int j = 0; j < n.length; j++)
                if(n[j] == target)
                    return j;
            return -1;
        public static void main(String[] args) throws IOException
            String path = "images/cougar.jpg";
            Object o = HighFive.class.getResource(path);
            BufferedImage image = ImageIO.read(((URL)o).openStream());
            new HighFive().examineColors(image);
    }

  • Get colors from image

    Is there any way to get the colors from an image in photoshop? Ideally, I would like a simple process to get a swatch collection from an existing image.
    Thanks,
    CFH

    I don't know if this is the easiest way, but, change Mode to Indexed. Go to Mode>Color Table and Save the table with a new name. Then you should be able to load it in the Swatches palette from the flyout. Choose .act in the dropdown.

  • Get color from image

    Hey people, I'm new to Illustrator and have a question. I want to use a color from an image that I put into Illustrator.
    The exact things I did with the image are the following: copied it from Windows Photo Viewer into Illustrator, then put the 'cut out' effect on it, then copied it into a new Illustrator document that has a businesscard template and resized it fit the template's margins. Now I want to kind of 'enlengthen' the image by putting a square next to it. To make it look smooth, it has to have the same color as that side of the image of course. But that's my problem, I'm not able to select the color from the image and make a new color group with that specific color. The 'get color from selected artwork' button doensn't help much since I can't click it, for some reason the mouse turns into this 'can't click here' icon every time I move it on this button.
    Any help would be greatly appreciated!
    PS apologies for any unavoidable noobness

    To sample a color from a raster image, ShiftClick with the Eyedropper tool. (CS3)
    Always state what software version you are using.
    JET

  • Read yellow color from red and green colors

    hi everyone
    need help in extracting yellow color from red and green colors (RGB space).
    before that, the B channel was set to zero.
    can display RG and CMYK together (like Adobe Photoshop)?
    thanks.
    mySiti

    hi everyone
    need help in extracting yellow color from red and green colors (RGB space).
    before that, the B channel was set to zero.
    can display RG and CMYK together (like Adobe Photoshop)?
    thanks.
    mySiti

  • Auto copy one pixel row from image....

    Can someone help me write a script that:
    - from my selection (1 pixel row)
    - auto copy selected area to next row into new layer (up or down)... and so on (into the same second layer)... until it reaches the end of the image
    - the result is a photos with two layers; in the first is my image and in second is multicolored pattern

    I don’t see a problem; naturally the Selection should be a vertical column.
    One should include a check for this condition, I guess.
    // 2012, use it at your own risk;
    #target photoshop
    if (app.documents.length > 0) {
    var originalRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    myDocument = app.activeDocument;
    // new layer;
    var id14 = charIDToTypeID( "CpTL" );
    executeAction( id14, undefined, DialogModes.NO );
    var theLayer = myDocument.activeLayer;
    var theHeight = theLayer.bounds[3]-theLayer.bounds[1];
    var theCheck = false;
    var theCounter = 1;
    // duplicate, move and merge the layer;
    while (theCheck == false) {
    if (theLayer.bounds[0] > 0) {
    var theCopy = theLayer.duplicate();
    theCopy.translate(theLayer.bounds[0] - theLayer.bounds[2], 0);
    theCounter++;
    var theLayer = theCopy.merge();
    //$.writeln(theCounter);
    else {theCheck = true};
    // reset;
    app.preferences.rulerUnits = originalRulerUnits;

  • Detect pixel color from Raster

    Hi
    I am trying to count the number of white pixels I have in a grayscale TIFF image, using JAI I get a buffered image then pass in a portion of the image (raster) to a method. This works fine for some of my images and not at all with others, I have, after lots of pain and suffering ive found out that in some of the images a white pixel is 0 while in others it is -1.
    I am counting white pixels and considering all others black ...to allow bi-tonal and grayscale images alike. I am lost as far as these images are concerned ...my guess is that the info i need is in the sample model but i have spent more time researching the inner workings of image than the scope of my project requires already
    so im hoping someone can help me out here ...all i wanna do is detect a white pixel in a raster (hopefully this is as easy as it sounds)
    -Jerome BG

    Well after doin a bunch of reading and investigative work I know way more about image rendering and visualization than I ever wanted to know. So I know that you cant determine the pixel's color without the ColorModel, but since I can convert grayscale images to bi-tonal i know all ill have is 0 or 1 ...I still dunno how to use the ColorModel to determine which is which, but its not so important since all my images have white as 0.
    Any ways if anyone out there is as obtuse as my self just using:
    myRaster.getSample(x,y,band)(only one band for bi-tonal images) you get the bit as an int.
    If anyone knows how to determine how to find out rather white or black is 0 using the Raster and the ColorModel I would still like to know
    -Jeorme BG

  • Reading metadata to - from image files

    I am using Creative Suite CS4.  In CS3 I created two custom XMP metadata pages that I used to add information to RAW, TIF, PSD files.  The resulting custom panel could be seen and used in Bridge and Extensis Portfolio.  In CS4 that all changed.  I can create the GUI part of the panel using Flex Builder 3.
    My questions are 1) How do you get the controls to work (combo boxes with fixed lists, fields for text data and a note field), 2) how do I get the data from the image file, have it update when a field changes, read it back to the image file when closed, and 3) how do I get it to work in Bridge CS4 properly and also be readable to Extensis Portfolio.
    I have attached the CS3 files that were used to create the panels in CS3.
    Fred

    I am using Creative Suite CS4.  In CS3 I created two custom XMP metadata pages that I used to add information to RAW, TIF, PSD files.  The resulting custom panel could be seen and used in Bridge and Extensis Portfolio.  In CS4 that all changed.  I can create the GUI part of the panel using Flex Builder 3.
    My questions are 1) How do you get the controls to work (combo boxes with fixed lists, fields for text data and a note field), 2) how do I get the data from the image file, have it update when a field changes, read it back to the image file when closed, and 3) how do I get it to work in Bridge CS4 properly and also be readable to Extensis Portfolio.
    I have attached the CS3 files that were used to create the panels in CS3.
    Fred

  • Best way of removing color from image

    Hey Adobe Community,
    I'm Aaron. I have this image here: https://www.dropbox.com/s/zjpjq5mf8t02pn9/chimera1-Recovered.jpg
    What I'm trying to do is create an outline for a pattern, something like the hot dog in the pattern here: https://m1.behance.net/rendition/modules/59556275/disp/36d76e9e0f33274e8a75ea77fd69b731.jp g
    Anyone know if this is possible and what is the best way of doing it? I'd like to keep the outline throughout the whole design of the chimera. Doesn't matter how tedious , I just need some ideas.

    I know of no good way to do this in Photoshop.
    The quickest way I know is to place the original photo in Illustrator, reduce the opacity of it somewhat, and use the pen tool on another layer to draw what you want. Depending on the nature of the image, it can be tedious, but you don't mind that.  :+)
    Good luck.

  • Kuler's Create colors from image not working

    Whenever I try to create a color scheme from a photo, the
    little spin graphic hangs and the percentage done gets stuck on 19%
    or 31%. It's not working. Any help??

    Hi,
    We were experiencing issues with one of our servers
    yesterday. It should all be working now. Please let us know if
    you're still experiencing the same problems.
    Thanks,
    The Kuler Team

  • How to create 2-color Pantone image from jpeg logo

    Working in CS3 under XP, I need to convert a jpeg rvb image of a logo  into a 2-color pantone image to import it into an Illustrator file. I  can isolate the logo's two distinct colors using the select wand and  then tried filling the selections with the closest Pantone colors, but  the rvb layers still seem to exist. I have saved in .eps DCS2, but the  imported colors when sampled in Illustrator are still rvb/cmyk. Is there  a way to isolate the shapes/colors and then transfer them as vector  images into Illustrator, where I could fill them with the Pantone  colors? Or a simpler way not necessarily using Photoshop? Thanks very much!

    Is this a vector image or pixels? EPS can be both.
    Better than selecting it with automatic functions like magic wand is to draw it manually in Illustrator. If it already is vector (like shape layers), then you can just copy the paths from Photoshop and paste into Illustrator.

  • Read Pixels From Application

    Hi. I'm working on a project for fun in which I need the values associated with pixels at certain locations on a window of an application, which may or may not be changing.
    I've been looking around, but have only been able to find support for reading in pixels from a saved image. One bad way to do it would be to write a script that takes a screen shot and accesses the pixel from the saved image. However, I was hoping for a more direct way to do this because I will want to run this script many times and at a very rapid rate (the higher frequency, the better). The way I suggested would waste both processing time and memory. Is there a way to just have a script pull off the pixel value corresponding to an (x,y) coordinate relative to the entire screen?
    Any other suggestions?
    Thanks,
    Steve

    Hi Steve--
    This thread is a mess, because of all the formatting problems I was having -- not to mention that I somehow got the wrong idea of what you were after. Perhaps you could post your question again as a new thread, with whatever clarification you feel might help?
    In the meantime, I've been trying to figure out exactly what you're up to and my guess is that it might be (probably is?) dynamic image editing for various animation effects. I can see that the code I posted might be useful for size animation, so I tried this with an open Preview window
    (hope there are no formatting issues here):
    set TargetWinName to "MyPicture.jpg"
    -- you must enter the name of your window, or get script to enter it
    set Wins_ to windows of application "Preview" -- you must enter relevant application
    repeat with w_ from 1 to count items of Wins_
    set WinName to name of item w_ of Wins_
    if WinName contains " — " then set WinName to do shell script "echo " & quoted form of WinName & " | sed -e 's/(same note as before)*$//' -e 's/ — //'"
    if WinName is TargetWinName then
    repeat 100 times
    set WinBounds to bounds of item w_ of Wins_
    set bounds of item w_ of Wins_ to {item 1 of WinBounds, item 2 of WinBounds, (0.95 * (item 3 of WinBounds)), (0.95 * (item 4 of WinBounds))}
    end repeat
    exit repeat
    end if
    end repeat
    For me, this essentially makes the image vanish into its upper left corner, but there are all kinds of things you might do. I'm a bit surprised that it works as well as it does, as Preview has limited scriptability.
    I'm assuming (but may be wrong) that you want to do something like this with pixel color -- I don't know how to do that offhand, but I'm thinking about it. New post?
    Message was edited by: osimp

  • Convert colour images to grayscale images & get pixel data from them

    Is the code below correct to convert colour images to grayscale images in Java?
    public void convertToGrayscale (String sourceName,String destName) throws Exception {
    JPEGImageDecoder decoder=JPEGCodec.createJPEGDecoder(new FileInputStream(sourceName));
    JPEGImageEncoder encoder=JPEGCodec.createJPEGEncoder(new FileOutputStream(destName));
    BufferedImage sourceImg=decoder.decodeAsBufferedImage();
    BufferedImageOp op =new ColorConvertOp(
              ColorSpace.getInstance(ColorSpace.CS_GRAY),null);
         BufferedImage destImg = op.filter(sourceImg,null);
    encoder.encode(destImg);
    decoder = null;
    encoder = null;
    When I get grayscale images from the code below, I would like to access the pixels of those images. So I tried to do:
    byte[] dd=((DataBufferByte)mImage.getRaster().getDataBuffer()).getData();
    BUT the data result array is not 0-255. Could anyone suggest how to obtain pixel data from grayscale images?
    In case that my code shown is not correct or suitable, please give your advice. What I would like to do are in the steps as follows:
    1 change 100*70 jpeg-images to 100*70 grayscale images.
    2 create two dimensional array of pixel data (example [100][70]) from converted images. The number in the array should be between 0-255, right??? And 0 refers to black colour and 255 refers to white colour???
    I am confused about grayscale images. Please help.
    Thank you so much

    I am not sure i understand what is the problem exactly.
    Structure of DataBuffer is described by SampleModel used by same Raster
    object. E.g. it might be 1 byte per xipex or 4 bytes per pixel.
    In your example convertToGrayscale saves images to file as JPEG and
    it seems you later read it back. It is possible what image you read back
    is not greyscale but ARGB and data buffer has different format.
    Technically, if you just need level of grey you may simply
    call getRGB on your output image. Grey is uniform mix of R, G and B.
    Also, instead of ColorConverOp you may dimply create output image of
    grayscale type and draw your color input image with drawImage().
    If none of these helps please try to provide more details.

  • Reading grayscale values from saved image

    Hi,
    I've written several methods that crop, convert to grayscale, histogram equalise and then resize a colour jpeg image for preparing sets of images for a face detection neural network. The next thing I want to do is to write a method that allows me to read that saved grayscale images pixel values back as singular grayscale values from the RGB values that were used to save the jpeg. I used this code to create the 2D array of grayscale pixel values
          for (int i = 0; i < imageWidth; i++)
                for (int j=0; j <imageHeight; j++)
                    grayRGB[i][j] = (rgb[i][j] & 0xff000000) | (eqGray[i][j]<<16) | (eqGray[i][j]<<8) | (eqGray[i][j]);
                    img.setRGB(i, j, grayRGB[i][j]);
                }and then used this code to resize the image:
            BufferedImage resized = new BufferedImage(20,20,1);
            Graphics2D g = resized.createGraphics();
            g.drawImage(img, 0, 0, 20, 20, null);
            g.dispose();my class gets the RGB values on instantiation as follows:
            //get RGB pixel values for image loaded
            for (int i = 0; i < imageWidth; i++)
                for (int j=0; j <imageHeight; j++)
                    rgb[i][j]= inputImage.getRGB(i,j);
                    //perform bitwise shift rgb information values to obtain appropriate values for each colour pixel
                    r[i][j]=  (rgb[i][j] >> 16) &0xff;
                    g[i][j]=  (rgb[i][j] >> 8) &0xff;
                    b[i][j]=  (rgb[i][j]) &0xff;
                }Is there a way to get the grayscale values directly from an image that is already converted to grayscale without having to perform the grayscale conversion method again, perhaps using a similar bitwise shift?
    Thanks
    Nick

    answering this myself for those lost souls like i was a while ago:
    the answer is very simple when you get to know it :) : use a signed type for your image. this can be achieved by using the Format Operator (javax.media.jai.operator.FormatDescriptor). an example as follows :
            BufferedImage bufferedImage= someimage...
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(bufferedImage);
            pb.add(DataBuffer.TYPE_SHORT);
            RenderedImage formattedImage =
                    JAI.create("format", pb, null);
    // you may use as well TYPE_DOUBLE or TYPE_FLOATimage could be of any type such as PlanarImage, BufferedImage, RenderedImage etc..
    then all you need to do is read your pixel values by using an iterator such as RectIter or RandomIter to access pixel values etc..
    San

  • How can I get to read the pixels in an image?

    Please see details of my code below. What I am doing is trying to obtain the pixels for an image. there is an initial image of a certain size, which is then split into smaller portions.
    The problem I'm getting is that pixels can not be read past the middle of the original image. I hope I have explained this so it can be understood. I have included the class that I am working on
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package MandelbrotConstruction.compression;
    import java.awt.*;
    import java.awt.color.ColorSpace;
    import java.awt.geom.AffineTransform;
    import java.awt.image.*;
    import java.io.*;
    import java.util.ArrayList;
    import javax.imageio.ImageIO;
    import javax.swing.JPanel;
    * @author Charlene Hunter
    public class DisplayImg extends JPanel {
        private static BufferedImage image;
        private static ArrayList<Range> rangeLot;
        private static ArrayList<Domain> domainLot;
        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            int w = MainFrame.getJPanel1().getWidth();
            int h = MainFrame.getJPanel1().getHeight();
            Graphics2D g2 = (Graphics2D) g;
            File img = MainFrame.getImgFile();
            image = null;
            if (img != null) {
                try {
                    image = ImageIO.read(img);
                    //filter the image with a grayscale
                    ColorConvertOp grayOp = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
                    image = grayOp.filter(image, null);
                    //scale image to the size of the panel
                    AffineTransform at = new AffineTransform();
                    at.scale(256.0 / image.getWidth(), 256.0 / image.getHeight());
                    AffineTransformOp resizeOp = new AffineTransformOp(at, null);
                    image = resizeOp.filter(image, null);
                    ArrayList<Range> r = createRanges(image, 3);
                    ArrayList<Domain> d = createDomains(image);
                    int i = 0;
                    for (Domain dom : d) {
                        System.err.println("this is " + i);
                        System.out.println(dom.getPixels());
                        i++;
                    CompareClass comparer = new CompareClass(r, d);
                } catch (IOException e) {
                    System.err.println("IOException");
            g2.drawImage(image, null, 0, 0);
        public static ArrayList<Range> createRanges(BufferedImage bi, int divisions) {
            int w = bi.getWidth();
            int h = bi.getHeight();
            rangeLot = new ArrayList<Range>();
            int k = (int) Math.pow(2, divisions);
            for (int x = 0; x < w; x = x + (w / k)) {
                for (int y = 0; y < h; y = y + (h / k)) {
                    BufferedImage range = bi.getSubimage(x, y, w / k, h / k);
                    double[] pix = range.getRaster().getPixels(x, y, range.getWidth(), range.getHeight(), (double[]) null);
                    Range r = new Range(x, y, range, pix);
                    rangeLot.add(r);
            return rangeLot;
        public static ArrayList<Domain> createDomains(BufferedImage bi) {
            int w = bi.getWidth();
            int h = bi.getHeight();
            domainLot = new ArrayList<Domain>();
            int step = 4;
            for (int x = 0; x < w - step; x = x + step) {
                for (int y = 0; y < h - step; y = y + step) {
                    BufferedImage domain = bi.getSubimage(x, y, 2 * step, 2 * step);
                    double[] pix = domain.getRaster().getPixels(x, y, domain.getWidth(), domain.getHeight(), (double[]) null);
                    Domain d = new Domain(x, y, domain, pix);
                    domainLot.add(d);
            return domainLot;
    }If what I have included is not sufficient, please let me know. the problem is only arising when the pixels are being obtained for the subimage
    Thanks

    Hi, the error message I am getting is (i'm printing out the x,y values and width and height so that I can see what going on) the whole image is 512x512, and I am grabbing pixels for squares of 64x64, but when it gets to 256 it throws an exception. I don'd understand why
    (x: 0, y: 0)
    width: 64, height: 64
    done!
    (x: 0, y: 64)
    width: 64, height: 64
    done!
    (x: 0, y: 128)
    width: 64, height: 64
    done!
    (x: 0, y: 192)
    width: 64, height: 64
    done!
    (x: 0, y: 256)
    width: 64, height: 64
    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
            at java.awt.image.ComponentSampleModel.getSampleDouble(ComponentSampleModel.java:807)
            at java.awt.image.SampleModel.getPixels(SampleModel.java:823)
            at java.awt.image.Raster.getPixels(Raster.java:1613)
            at MandelbrotConstruction.compression.DisplayImg.createRanges(DisplayImg.java:83)
            at MandelbrotConstruction.compression.DisplayImg.paintComponent(DisplayImg.java:51)
            at javax.swing.JComponent.paint(JComponent.java:1006)
            at javax.swing.JComponent.paintChildren(JComponent.java:843)
            at javax.swing.JComponent.paint(JComponent.java:1015)
            at javax.swing.JComponent.paintChildren(JComponent.java:843)
            at javax.swing.JComponent.paint(JComponent.java:1015)
            at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
            at javax.swing.JComponent.paintChildren(JComponent.java:843)
            at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4979)
            at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4925)
            at javax.swing.JComponent.paint(JComponent.java:996)
            at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
            at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
            at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
            at java.awt.Container.paint(Container.java:1709)
            at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
            at sun.awt.RepaintArea.paint(RepaintArea.java:224)
            at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
            at java.awt.Component.dispatchEventImpl(Component.java:4060)
            at java.awt.Container.dispatchEventImpl(Container.java:2024)
            at java.awt.Window.dispatchEventImpl(Window.java:1791)
            at java.awt.Component.dispatchEvent(Component.java:3819)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Maybe you are looking for

  • Commenting in Reader Not Working

    I am using Pro 9 and have enabled commenting for Reader users.  My collaboration is file based (stored on local server with full access rights).  I have two problems. 1) Comments made by others are not visible in pure Reader users.  I can see the com

  • Setting up one IMAC in a windows environment

    I am a systems administrator in a small company that operates in a 100% windows environment. We have no one on staff with any support knowledge when it comes to apple. I have one individual ( a graphic designer) that has requested a Imac. The reason;

  • Cannot logon through SAP Logon

    Hello Guru's, I have create an instance (ERP Foundation Extension powered by SAP HANA ) CAL successfully. however, I'm not able to connect to SAP with my SAP Logon. When I click on Connect, I use the SAP Logon shortcut to have access to my system and

  • Prevent apps and icons from being rearranged or deleted?

    Is there a way to prevent apps and icons from being rearranged or deleted? My three year old son likes to move them around and delete them. I don't want to lock him out because he loves to play many of the learning apps and games.

  • HT4906 why doesn't iPhoto shared photo stream update

    I have created a shared phot stream on my IOS devices and they update ok. I have invited others and they are allowed to post. I can see all posted photo's on all IOS devices. I cannot see any phot's posted by oyhers on my Mac in iPhoto. iPhoto update