Is there an opposite to BufferedImageCreator?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there an opposite to BufferedImageCreator?

mobitel
I want to have BufferedImages to ImagePlus etc.

How is that possible?
Reply | Threaded
Open this post in threaded view
|

Re: Is there an opposite to BufferedImageCreator?

Sami Badawi-2
Hi Mobitel,

BufferedImage is a subclass of java.awt.Image.
You can just use this constructor for ColorProcessor to get from a
java.awt.image.BufferedImage to a ColorProcessor:

/**Creates a ColorProcessor from an AWT Image. */
public ColorProcessor(Image img) {
    width = img.getWidth(null);
    height = img.getHeight(null);
    pixels = new int[width * height];
    PixelGrabber pg = new PixelGrabber(img, 0, 0, width, height,
pixels, 0, width);
    try {
            pg.grabPixels();
    } catch (InterruptedException e){};
    createColorModel();
    fgColor = 0xff000000; //black
    resetRoi();
}

ImagePlus contains a ImageProcessor (ByteProcessor, ShortProcessor,
ColorProcessor), but it is really the ImageProcessor that contains the
image that you work on.

-Sami Badawi
http://www.shapelogic.org
Reply | Threaded
Open this post in threaded view
|

Re: Is there an opposite to BufferedImageCreator?

Wayne Rasband
In reply to this post by mobitel
> I want to have BufferedImages to ImagePlus etc.

BufferedImage is a subclass of Image so you can use the ImagePlus
constructor that creates an ImagePlus from an Image.

      ImagePlus imp = new ImagePlus("title", bufferedImage);

-wayne