NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 1205 - ImageProcessor.flipHorizontal()/flipVertical() requires use of updateImage()
ImageProcessor.flipHorizontal()/flipVertical() requires use of updateImage()
Status: RESOLVED WONTFIX
Product: ImageJ
Classification: Unclassified
Component: Legacy
unspecified
PC Windows
: P5 normal
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2015-12-11 19:00 CST by Denis Loginov
Modified: 2015-12-11 22:15 CST
1 user (show)

See Also:

Description Denis Loginov 2015-12-11 19:00:10 CST
I was using ImageProcessor.flipHorizontal()/flipVertical() and found that its behavior is sometimes inconsistent, i.e. it may flip the image as referred to by ImageProcessor, but not necessarily the same image when referred by ImagePlus. In these cases I have to force the update using ImagePlus.updateImage(). Could you please elaborate if that is the intended behavior?

Specific instance is:

BufferedImage img = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_USHORT_GRAY);
img.getRaster().setDataElements(0, 0, WIDTH, HEIGHT, objImage);
ImagePlus imp = new ImagePlus("", img);
imp.show(); // shows original image
ImageProcessor ip = imp.getProcessor();
ip.flipVertical();
ip.flipHorizontal();
ImagePlus impNew = new ImagePlus("", ip);
impNew.show(); // flipped image
imp.show(); // old image (!)

If one now issues

imp.updateImage();

then imp.show() will show the correct (flipped) image.

I'm encountered this issue with the latest release version (1.50e).

Thank you.
Comment 1 Wayne Rasband 2015-12-11 22:15:51 CST
Use the updateAndDraw() method. It updates the ImagePlus from the pixel data in the associated ImageProcessor and updates the display. The setProcessor() method will also work. Here is a runnable JavaScript example:

  imp = IJ.openImage("http://imagej.nih.gov/ij/images/boats.gif");
  imp.show();
  ip = imp.getProcessor();
  ip.flipVertical();
  ip.flipHorizontal();
  imp.updateAndDraw();
  //imp.setProcessor(ip);