ImageProcessor Pixel Watcher

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

ImageProcessor Pixel Watcher

kacollins
I am writing a plugin and need to perform some actions when one or more pixel values have changed in an ImagePlus/ImageProcessor. I have experimented with the imageUpdated method of ImageListener, but this listener seems to respond to other actions related to an image in addition to pixel changes. For instance, imp.updateAndDraw() causes imageUpdated to run 5 times. I also have other image elements that are part of the frame that contains the ImageProcessor/ImagePlus and changes to those pixels cause imageUpdated to run as well.

Any ideas on how to be notified if and only if pixels of an ImageProcessor/ImagePlus have changed?

Thanks in advance,
Karen
Reply | Threaded
Open this post in threaded view
|

Re: ImageProcessor Pixel Watcher

Michael Schmid
Hi Karen,

apart from the ImageListener, there is no method that I am aware of  
to get notified if an image (ImagePlus, ImageProcessor) changes. Of  
course, what you can (and should) do is check whether the  
imageUpdated event corresponds to the ImagePlus you are interested in.

To avoid performing you action too often, you could
- use a separate thread with wait and notify, as in theDynamic  
Profiler plugin (ImageJ website) or Pixel_Inspector (http://
imagejdocu.tudor.lu/). This also avoids slowing down the event queue  
in case your action is time-consuming.
- calculate a checksum of the ImageProcessor.getPixels() array and  
see whether it has changed. Arrays.hashcode(pixels) would be a  
possible solution for such a checksum.

Hope this helps,

Michael
________________________________________________________________

On 29 Nov 2010, at 09:29, kacollins wrote:

> I am writing a plugin and need to perform some actions when one or  
> more pixel
> values have changed in an ImagePlus/ImageProcessor. I have  
> experimented with
> the imageUpdated method of ImageListener, but this listener seems  
> to respond
> to other actions related to an image in addition to pixel changes. For
> instance, imp.updateAndDraw() causes imageUpdated to run 5 times. I  
> also
> have other image elements that are part of the frame that contains the
> ImageProcessor/ImagePlus and changes to those pixels cause  
> imageUpdated to
> run as well.
>
> Any ideas on how to be notified if and only if pixels of an
> ImageProcessor/ImagePlus have changed?
>
> Thanks in advance,
> Karen
Reply | Threaded
Open this post in threaded view
|

Re: ImageProcessor Pixel Watcher

kacollins
Hi Michael,
     Thank you for the ideas. A "Pixel Listener" would be nice to have, but since that functionality doesn't seem to exist, I will experiment with the ideas you mentioned.
Karen

On 11/29/2010 7:45 AM, Michael Schmid-3 [via ImageJ] wrote:
Hi Karen,

apart from the ImageListener, there is no method that I am aware of  
to get notified if an image (ImagePlus, ImageProcessor) changes. Of  
course, what you can (and should) do is check whether the  
imageUpdated event corresponds to the ImagePlus you are interested in.

To avoid performing you action too often, you could
- use a separate thread with wait and notify, as in theDynamic  
Profiler plugin (ImageJ website) or Pixel_Inspector (<a class="moz-txt-link-freetext" href="http://">http://
imagejdocu.tudor.lu/). This also avoids slowing down the event queue  
in case your action is time-consuming.
- calculate a checksum of the ImageProcessor.getPixels() array and  
see whether it has changed. Arrays.hashcode(pixels) would be a  
possible solution for such a checksum.

Hope this helps,

Michael
________________________________________________________________

On 29 Nov 2010, at 09:29, kacollins wrote:

> I am writing a plugin and need to perform some actions when one or  
> more pixel
> values have changed in an ImagePlus/ImageProcessor. I have  
> experimented with
> the imageUpdated method of ImageListener, but this listener seems  
> to respond
> to other actions related to an image in addition to pixel changes. For
> instance, imp.updateAndDraw() causes imageUpdated to run 5 times. I  
> also
> have other image elements that are part of the frame that contains the
> ImageProcessor/ImagePlus and changes to those pixels cause  
> imageUpdated to
> run as well.
>
> Any ideas on how to be notified if and only if pixels of an
> ImageProcessor/ImagePlus have changed?
>
> Thanks in advance,
> Karen



View message @ http://imagej.588099.n2.nabble.com/ImageProcessor-Pixel-Watcher-tp5783572p5784198.html
To unsubscribe from ImageProcessor Pixel Watcher, click here.