Login  Register

Re: ImageProcessor Pixel Watcher

Posted by Michael Schmid on Nov 29, 2010; 11:11am
URL: http://imagej.273.s1.nabble.com/ImageProcessor-Pixel-Watcher-tp3686338p3686339.html

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