Login  Register

Refresh open image

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

Refresh open image

AJBell
59 posts
Dear list,

I have written a plugin that takes an ROI of a main image and pastes it into a blank small image window for processing. Currently, to move onto another ROI I am closing the small window and re-creating a new one. Whilst functional, this seems somewhat inelegant. Is there a simple command that will effectively "wipe-clean" the small image - like with an etch-a-sketch?

I had thought something like imp.flush would work, but this results in the window freezing up. The only other option I can see right now is to set the pixel values to 255:

ip.setValue(255);  
ip.fill();

Is there a better/more efficient method?

Dr Andrew Bell
Research Associate
Department of Infection, Immunity and Inflammation
University of Leicester
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Refresh open image

Michael Schmid
2136 posts
Hi Andrew,

if you have always the same ROI size that you wan to copy to the small window, you don't need to erase it. Either use copy&paste (make sure the Paste Control mode is 'copy') or the ij.process.Blitter class.

If your rois have different size, you have to rease the image before 'paste'. Your way of erasing is ok. If your application needs to be extremely fast, you could get the pixels array with (byte[])(ip.getPixels()) and use java.util.Arrays.fill(pixels, (byte)255. For small images, you won't notice the speed difference, it's extremely fast anyhow.

ImagePlus.flush() is used to free memory when an image is closed.

Michael
________________________________________________________________
On Feb 6, 2014, at 17:17, AJBell wrote:

> Dear list,
>
> I have written a plugin that takes an ROI of a main image and pastes it into
> a blank small image window for processing. Currently, to move onto another
> ROI I am closing the small window and re-creating a new one. Whilst
> functional, this seems somewhat inelegant. Is there a simple command that
> will effectively "wipe-clean" the small image - like with an etch-a-sketch?
>
> I had thought something like imp.flush would work, but this results in the
> window freezing up. The only other option I can see right now is to set the
> pixel values to 255:
>
> ip.setValue(255);  
> ip.fill();
>
> Is there a better/more efficient method?
>
> Dr Andrew Bell
> Research Associate
> Department of Infection, Immunity and Inflammation
> University of Leicester

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Refresh open image

AJBell
59 posts
Hi Michael,

Thanks for the reply. The image is only a couple of hundred pixels square, so I'll stick to the ip.setValue(255) method.

Andrew

Michael Schmid-3 wrote
Hi Andrew,

if you have always the same ROI size that you wan to copy to the small window, you don't need to erase it. Either use copy&paste (make sure the Paste Control mode is 'copy') or the ij.process.Blitter class.

If your rois have different size, you have to rease the image before 'paste'. Your way of erasing is ok. If your application needs to be extremely fast, you could get the pixels array with (byte[])(ip.getPixels()) and use java.util.Arrays.fill(pixels, (byte)255. For small images, you won't notice the speed difference, it's extremely fast anyhow.

ImagePlus.flush() is used to free memory when an image is closed.

Michael
________________________________________________________________
On Feb 6, 2014, at 17:17, AJBell wrote:

> Dear list,
>
> I have written a plugin that takes an ROI of a main image and pastes it into
> a blank small image window for processing. Currently, to move onto another
> ROI I am closing the small window and re-creating a new one. Whilst
> functional, this seems somewhat inelegant. Is there a simple command that
> will effectively "wipe-clean" the small image - like with an etch-a-sketch?
>
> I had thought something like imp.flush would work, but this results in the
> window freezing up. The only other option I can see right now is to set the
> pixel values to 255:
>
> ip.setValue(255);  
> ip.fill();
>
> Is there a better/more efficient method?
>
> Dr Andrew Bell
> Research Associate
> Department of Infection, Immunity and Inflammation
> University of Leicester

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html