problem with showing 16bit greyscale image

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

problem with showing 16bit greyscale image

Peter Nagy-2
Dear list members,
The plugin below extracts a column from an image stack. It works fine
for 8-bit grey scale images (when replacing the short variables with
byte), but for 16-bit images the result is strange. The image data is
there in the output image, because when I place the mouse over the
image, the pixel values are displayed. But there are two problems:
1. when I check the max value of the image with getMax(), I get zero.
2. the image LUT is such that everything is white.


And a 3rd question, when I close the newly created image window, I'm
not asked if I would like to save it.

Can anyone tell me where the problem is?

Thanks,
Peter



public void run(ImageProcessor oldproc) {

short [] newpixels0,pixels0;
ImageProcessor ip;
int w=oldproc.getWidth();
int h=oldproc.getHeight();
int z=oldimplus.getStackSize();
ImageStack oldstack=oldimplus.getStack();
ImageStack s=new ImageStack(100,100);
ImageProcessor temp_ip=oldproc.createProcessor(100,100);
pixels0=new short[w*h];
for (int i=1;i<=z;i++) {
newpixels0=new short[100*100];
pixels0=(short []) oldstack.getPixels(i);
for (int y=100;y<200;y++) {
int offset1_image=y*w;
int offset1_roi=(y-100)*100;
for (int x=100;x<200; x++) {
newpixels0[offset1_roi+x-100]=pixels0[offset1_image+x];
}
}
s.addSlice(null,newpixels0);
}
ImagePlus e;
e=new ImagePlus("extracted",s);
e.show();
ImageProcessor e_ip;
e_ip=e.getProcessor();
IJ.write(Double.toString(oldproc.getMax()));
IJ.write(Double.toString(e_ip.getMax()));

}
Reply | Threaded
Open this post in threaded view
|

Applet on a Mac

Jon Harman
Dear list members,

I have written an applet using ImageJ with my plugin compiled in.  It
works for me on a PC using IE, Firefox, or Opera.  Someone with a Mac
reported to me that it doesn't work on a Mac using Firefox.  Since I
don't have a Mac I can't check this.  I wonder if some on this group
with more experience than I could look at these two emails and advise me
if this is a real problem or maybe just confusion on the part of the
user.  The ImageJ version of the Applet is 1.38j.

[His first email]:
A window pops up, with what looks like a few buttons for image editing,
but there are no menus.  So for instance there's no way to load a file.  
I got far enough to convince myself I wasn't just missing something, but
I didn't try a lot of debugging . . . it could be as simple as some
security setting I suppose.  I can try and get more specifics later.


[Follow-up email]:
First, I found that it does work in Safari, although it looks a bit
odd.  I think the problem is in the way menus are done in OS X (in the
same menu bar along the top of the screen for all applications) as
opposed to the way they are done in nearly ever other operating system
(in the same window as the application).  When it works in Safari, there
are many menu options, some with duplicate names (like "File") but it
works.  In Firefox, no new menus appear and the duplicated ones cease to
function.

I've attached several screenshots from trying to use it in Firefox
(2.0.0.3) and Safari (2.0.4) in OS X 10.4.9.
[I've deleted the screenshots.  They show that Safari has two sets of
menus, the second set being ImageJ menus.  Firefox has only one set of
menus, not including any ImageJ menus.]

For java:
[wotan:~] bclee% java -version
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164)
Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing)


My applet is at:
http://www.dstretch.com/IJapplet/ImageJApplet.html

Thanks for any help.
Jon
Reply | Threaded
Open this post in threaded view
|

Re: problem with showing 16bit greyscale image

Michael Schmid
In reply to this post by Peter Nagy-2
Hi Peter,

for 16-bit images, you have to call ip.findMinAndMax().

In contrast to 8-bit images, the data range of 16-bit images
can vary a lot, so there is no default.

> And a 3rd question, when I close the newly created image window, I'm
> not asked if I would like to save it.
>
ImageJ does not ask whether to save unchanged images.
    imp.changes = true;
(where imp is the ImagePlus) should help.

Michael
________________________________________________________________

On 12 May 2007, at 11:36, Peter Nagy wrote:

> Dear list members,
> The plugin below extracts a column from an image stack. It works fine
> for 8-bit grey scale images (when replacing the short variables with
> byte), but for 16-bit images the result is strange. The image data is
> there in the output image, because when I place the mouse over the
> image, the pixel values are displayed. But there are two problems:
> 1. when I check the max value of the image with getMax(), I get zero.
> 2. the image LUT is such that everything is white.
>
>
> And a 3rd question, when I close the newly created image window, I'm
> not asked if I would like to save it.
>
> Can anyone tell me where the problem is?
>
> Thanks,
> Peter
>
>
>
> public void run(ImageProcessor oldproc) {
>
> short [] newpixels0,pixels0;
> ImageProcessor ip;
> int w=oldproc.getWidth();
> int h=oldproc.getHeight();
> int z=oldimplus.getStackSize();
> ImageStack oldstack=oldimplus.getStack();
> ImageStack s=new ImageStack(100,100);
> ImageProcessor temp_ip=oldproc.createProcessor(100,100);
> pixels0=new short[w*h];
> for (int i=1;i<=z;i++) {
> newpixels0=new short[100*100];
> pixels0=(short []) oldstack.getPixels(i);
> for (int y=100;y<200;y++) {
> int offset1_image=y*w;
> int offset1_roi=(y-100)*100;
> for (int x=100;x<200; x++) {
> newpixels0[offset1_roi+x-100]=pixels0[offset1_image+x];
> }
> }
> s.addSlice(null,newpixels0);
> }
> ImagePlus e;
> e=new ImagePlus("extracted",s);
> e.show();
> ImageProcessor e_ip;
> e_ip=e.getProcessor();
> IJ.write(Double.toString(oldproc.getMax()));
> IJ.write(Double.toString(e_ip.getMax()));
>
> }
Reply | Threaded
Open this post in threaded view
|

Re: Applet on a Mac

ctrueden
In reply to this post by Jon Harman
Hi Jon,

I tried it, and I have the same problems on Mac OS X (behavior in
Firefox and Safari is as you describe). I also see the problems with
the ImageJ applet on the ImageJ web site.

Normally, this behavior is controlled with the
apple.laf.useScreenMenuBar property (set to true to use the Mac menu
bar rather than Windows-style menus beneath the application's title
bar).

I did some searching but was unable to find much; the closest I found
was this Mozilla bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=132594

It seems like something similar is going on with the ImageJ applet.

-Curtis

On 5/12/07, Jon Harman <[hidden email]> wrote:

> Dear list members,
>
> I have written an applet using ImageJ with my plugin compiled in.  It
> works for me on a PC using IE, Firefox, or Opera.  Someone with a Mac
> reported to me that it doesn't work on a Mac using Firefox.  Since I
> don't have a Mac I can't check this.  I wonder if some on this group
> with more experience than I could look at these two emails and advise me
> if this is a real problem or maybe just confusion on the part of the
> user.  The ImageJ version of the Applet is 1.38j.
>
> [His first email]:
> A window pops up, with what looks like a few buttons for image editing,
> but there are no menus.  So for instance there's no way to load a file.
> I got far enough to convince myself I wasn't just missing something, but
> I didn't try a lot of debugging . . . it could be as simple as some
> security setting I suppose.  I can try and get more specifics later.
>
>
> [Follow-up email]:
> First, I found that it does work in Safari, although it looks a bit
> odd.  I think the problem is in the way menus are done in OS X (in the
> same menu bar along the top of the screen for all applications) as
> opposed to the way they are done in nearly ever other operating system
> (in the same window as the application).  When it works in Safari, there
> are many menu options, some with duplicate names (like "File") but it
> works.  In Firefox, no new menus appear and the duplicated ones cease to
> function.
>
> I've attached several screenshots from trying to use it in Firefox
> (2.0.0.3) and Safari (2.0.4) in OS X 10.4.9.
> [I've deleted the screenshots.  They show that Safari has two sets of
> menus, the second set being ImageJ menus.  Firefox has only one set of
> menus, not including any ImageJ menus.]
>
> For java:
> [wotan:~] bclee% java -version
> java version "1.5.0_07"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164)
> Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing)
>
>
> My applet is at:
> http://www.dstretch.com/IJapplet/ImageJApplet.html
>
> Thanks for any help.
> Jon
>