Reading 16-bit PGM files

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

Reading 16-bit PGM files

Paul Dumais
I have discovered that reading a 16-bit PGM using the ImagePlus
constructor downsamples the resulting bufferedImage into 8 bits.

Does imagej support 16-bit pgm files?

Thanks,

Paul

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Reading 16-bit PGM files

ctrueden
Hi Paul,

[Note to others: Paul reported a similar problem with 16-bit PGMs with
SCIFIO:
https://github.com/scifio/scifio/issues/114
As part of that report, he shared a sample non-working 16-bit PGM file.]

I tested in ImageJ 1.48k, and it opens your sample file correctly as far as
I can tell.

That is, ImageJ reports the resultant image as 16 bits and the pixel probe
(by moving the mouse over the image) appears to be reporting 16-bit values.
Although it is somewhat suspicious that all values happen to be multiples
of 16. Perhaps the file is actually 12-bit data which has been scaled up?

The problem has also been fixed in SCIFIO, with a fix forthcoming for
Bio-Formats as well. New versions coming soon.

Regards,
Curtis


On Mon, Dec 16, 2013 at 6:59 PM, Paul Dumais <[hidden email]> wrote:

> I have discovered that reading a 16-bit PGM using the ImagePlus
> constructor downsamples the resulting bufferedImage into 8 bits.
>
> Does imagej support 16-bit pgm files?
>
> Thanks,
>
> Paul
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Fwd: Reading 16-bit PGM files

Paul Dumais
In reply to this post by Paul Dumais
I was just calling it incorrectly.


---------- Forwarded message ----------
From: Rasband, Wayne (NIH/NIMH) [E] <[hidden email]>
Date: Tue, Dec 17, 2013 at 4:15 PM
Subject: Re: Reading 16-bit PGM files
To: Paul Dumais <[hidden email]>



On Dec 17, 2013, at 6:03 PM, Paul Dumais wrote:

> Ah! That works, but when I get the bi via: bi =  new
> ImagePlus(path).getBufferedImage I get:
>
> #<BufferedImage BufferedImage@1079cfc8: type = 10 ColorModel:
> #pixelBits = 8 numComponents = 1 color space =
> java.awt.color.ICC_ColorSpace@63699caa transparency = 1 has alpha =
> false isAlphaPre = false ByteInterleavedRaster: width = 1280 height =
> 960 #numDataElements 1 dataOff[0] = 0>
>
> Is this a bug? It seems that my way of reading the file should work
> just as well unless documented otherwise.

The ImagePlus.getBufferedImage() method returns 8-bit and RGB
BufferedImages. I have updated the documentation.

Best regards,

-wayne

-wayne

> Thanks for you help! I'm back on track.
>
> Paul
>
> On Tue, Dec 17, 2013 at 3:28 PM, Rasband, Wayne (NIH/NIMH) [E]
> <[hidden email]> wrote:
>> On Dec 17, 2013, at 5:01 PM, Paul Dumais wrote:
>>
>>> Hi Wayne,
>>>
>>> Thanks Wayne. I'm using 1.48c. Is there a maven repo with 1.48m? If
>>> you do println on the BufferedImage object does it report the correct
>>> bit depth?
>>
>> 1.48c should work. I get a 16-bit BufferedImage using this JavaScript:
>>
>>  imp = IJ.openImage(path);
>>  ip = imp.getProcessor();
>>  bi = ip.get16BitBufferedImage();
>>  print(bi);
>>
>> Output:
>> BufferedImage@6f0c29fe: type = 11 ColorModel: #pixelBits = 16 numComponents = 1 color space = java.awt.color.ICC_ColorSpace@648bfdea transparency = 1 has alpha = false isAlphaPre = false ShortInterleavedRaster: width = 1280 height = 960 #numDataElements 1
>>
>> Best regards,
>>
>> -wayne
>>
>>> On Tue, Dec 17, 2013 at 2:54 PM, Rasband, Wayne (NIH/NIMH) [E]
>>> <[hidden email]> wrote:
>>>> Hi Paul,
>>>>
>>>> Your file opens as a 16-bit image using ImageJ 1.48m (see screenshot). Are you using an old version of ImageJ?
>>>>
>>>> Best regards,
>>>>
>>>> -wayne
>>>> [cid:[hidden email]]
>>>>
>>>>
>>>> On Dec 17, 2013, at 4:23 PM, Paul Dumais wrote:
>>>>
>>>>> Hi Wayne,
>>>>>
>>>>> Thanks for willing to look at this. My image is attached. I was going
>>>>> to try to hack the byte stream to see if the pgm header is mismatched
>>>>> to the actually raster data (although I don't know how that would
>>>>> look). Or maybe the print str of the BufferedImage object is
>>>>> misrepresenting the bit depth.
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Paul
>>>>>
>>>>> On Mon, Dec 16, 2013 at 7:29 PM, Rasband, Wayne (NIH/NIMH) [E]
>>>>> <[hidden email]> wrote:
>>>>>> On Dec 16, 2013, at 7:59 PM, Paul Dumais wrote:
>>>>>>
>>>>>>> I have discovered that reading a 16-bit PGM using the ImagePlus
>>>>>>> constructor downsamples the resulting bufferedImage into 8 bits.
>>>>>>>
>>>>>>> Does imagej support 16-bit pgm files?
>>>>>>
>>>>>> ImageJ should be able to open 16-bit PGM files. Send, or make available, an example of one of your images and I will try to figure out why ImageJ does not open it correctly.
>>>>>>
>>>>>> Best regards,
>>>>>>
>>>>>> -wayne
>>>>>>
>>>>> <2013-11-05 11-49-49_MCA000_65.3.pgm>
>>>>
>>

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