Fwd: snapshot and swapPixelArrays

Posted by Robert Lockwood on
URL: http://imagej.273.s1.nabble.com/snapshot-and-swapPixelArrays-tp5005347p5005357.html

---------- Forwarded message ----------
From: Michael Schmid <[hidden email]>
Date: Mon, Oct 28, 2013 at 8:47 AM
Subject: Re: snapshot and swapPixelArrays
To: [hidden email]



<<
if you have the original data as a snapshot in the background, the easiest
would be addressing the snapshot pixels array directly.  For 16-bit data:

ImageProcessor ip = imp.getProcessor();
short[] snapshotPixels = (short[])(ip.getSnapshotPixels());

short val = snapshotPixels[x + y*width];

This assumes you have a single image, not a stack.  There is no snapshot
(undo buffer) for an operation on a stack.
>>

Thanks, Michael, works well.

Nate

________________________________________________________________
On Oct 28, 2013, at 16:20, Robert Lockwood wrote:

> Thought I had this working but I don't. My (16 bit monochromeTIFF) images
> are very low contrast so I want to automatically enhance the contrast for
> display.  On the other hand I want to show the original datum at the
cursor.
>
> I have attempted to use Snapshot and swapPixelArrays but it doesn't work
as

> I expected. that is, backup the original data, enhance it, display it, and
> then swap the buffers so that the original pixel value can be retrieved.
>
> Display
>  Imp = IJ.openImage(inFile.getPath());
>  imp.getProcessor().snapshot();
>  ContrastEnhancer ce = new ContrastEnhancer();
>  ce.equalize(imp);
>  jImagePanel.updateImage(imp);
>  imp.getProcessor().swapPixelArrays();
>
> Get datum at cursor:
>  int X = e.getX();
>  int Y = e.getY();
>  int val = imp.getProcessor().getPixel(X, Y);
>
> I think I'm misunderstanding something ...
>
> Nate

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



--
When I was 12 I thought I would live forever.
So far, so good.

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