hello all
in my application i required to open .raw file as image in java i tried a lot to do this but dint get success. now can any any tell me how to use imajeJ's .raw opener class in my application. one think is that here i am not suppose to open file chooser or any imajeJ window. i just have my .raw file path in some string variable and i want image in buffered image variable using imajeJ library. many thanks any advance |
On May 24, 2012, at 7:02 AM, ashishdonvir wrote:
> hello all > > in my application i required to open .raw file as image in java i tried a > lot to do this but dint get success. > now can any any tell me how to use imajeJ's .raw opener class in my > application. > one think is that here i am not suppose to open file chooser or any imajeJ > window. i just have my .raw file path in some string variable and i want > image in buffered image variable using imajeJ library. Create a FileInfo object that describes the raw file then use the FileOpener class to open it. Here is a JavaScript example: path = "/Users/wayne/test.raw"; fi = new FileInfo(); fi.fileName = path; fi.fileType = FileInfo.GRAY8; fi.width = 512; fi.height = 512; fo = new FileOpener(fi); imp = fo.open(false); if (imp!=null) { bi = imp.getBufferedImage(); //new ImagePlus(path, bi).show() } -wayne |
hello wayne
thanks a lot it worked for me. now i have little issue. My i need to to set Little-endian byte order as true. so how to set this? my image gray scale image of size 1050 X 1580 and 16-bit Sined. please reply me soon. thanks in advance |
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Why get as buffered image gave me 8 bit image?
i have my raw data 16 bit when i stored the image using image plus it store as 16 bit the image is now what i want it turns black image and when save as buffered image it looks nice but image got of 8-bit. i use imajej file save r for both the image save i told above |
Hi Ashish,
the BufferedImage is what Java uses to display the image. It has a maximum bit depth of 8 bits (grayscale) or 8 bits per color (RGB); Java does not support higher bit depth. For supported types, see the "Field summary" in http://docs.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html Thus, save the image as 16-bit image, and use auto adjust Brightness&Contrast after loading it. Michael ________________________________________________________________ On May 27, 2012, at 17:43, ashishdonvir wrote: > Why get as buffered image gave me 8 bit image? > i have my raw data 16 bit when i stored the image using image plus it store > as 16 bit the image is now what i want it turns black image and when save as > buffered image it looks nice but image got of 8-bit. > i use imajej file save r for both the image save i told above _______________________________________________________ ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by ashishdonvir
On May 27, 2012, at 11:43 AM, ashishdonvir wrote:
> Why get as buffered image gave me 8 bit image? > i have my raw data 16 bit when i stored the image using image plus it store > as 16 bit the image is now what i want it turns black image and when save as > buffered image it looks nice but image got of 8-bit. > i use imajej file save r for both the image save i told above Use the ShortProcessor.get16BitBufferedImage() method to get a 16-bit BufferedImage. Here is a JavaScript example: path = "/Users/wayne/test.raw"; fi = new FileInfo(); fi.fileName = path; fi.fileType = FileInfo.GRAY16_UNSIGNED; fi.width = 1050; fi.height = 1580; fi.intelByteOrder = true; fo = new FileOpener(fi); imp = fo.open(false); if (imp!=null) { ip = imp.getProcessor(); bi = ip.get16BitBufferedImage(); //new ImagePlus(path, bi).show() } In a plugin, this line ip = imp.getProcessor(); will need to be changed to ShortProcessor ip = (ShortProcessor)imp.getProcessor(); -wayne _______________________________________________________ ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Michael Schmid
so after applying some imajeJ algorithm , how should i get 16 bit image from imagePlus as i have to apply some of my own algorithm to this 16 bit image?
|
I have "raw" images that are 16 bit gray scale (created by C/C++) with
pixels as USHORT. I have coded a java application that displays them and at no time do I explicitly convert to 8 bit. I just used ImageJ to read one of my files and saved it as a TIFF. Since the source file and TIFF file are about the same size I know the TIFF is not 8 bit. I've implemented AHF reader as well. I will supply some code if it's any use to you. Nate On Wed, Jun 6, 2012 at 2:41 AM, ashishdonvir <[hidden email]>wrote: > so after applying some imajeJ algorithm , how should i get 16 bit image > from > imagePlus as i have to apply some of my own algorithm to this 16 bit image? > > -- > View this message in context: > http://imagej.1557.n6.nabble.com/need-to-open-raw-file-using-imajeJ-libraries-tp4998785p4998919.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > 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 |
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Thank you very much it worked
|
Free forum by Nabble | Edit this page |