|
Bugzilla – Bug 1205 |
ImageProcessor.flipHorizontal()/flipVertical() requires use of updateImage() |
Last modified: 2015-12-11 22:15:51 CST |
| ⚠ |
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. |
| ImageProcessor.flipHorizontal()/flipVertical() requires use of updateImage() | |
|
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
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.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);