Hi,
I need java code to uncompress multi frame dicom image. Input : Compressed (Multi frame) dicom image (file or byte array). Output : Uncompressed dicom images. Thanks in advance. Regards, Phanikanth |
Hi,
Are you tried with Loci format or BioFormat? They are perfect on these things. I also using bioFormat jar for opening my MultiFrame Dicom images as well as Single Frame. ----- Original Message ----- From: "vmunukutla" <[hidden email]> To: <[hidden email]> Sent: Friday, January 02, 2009 3:23 PM Subject: Need java code to uncompress a multiframe DICOM > Hi, > > I need java code to uncompress multi frame dicom image. > > Input : Compressed (Multi frame) dicom image (file or byte array). > Output : Uncompressed dicom images. > > Thanks in advance. > > Regards, > Phanikanth > -- > View this message in context: > http://n2.nabble.com/Need-java-code-to-uncompress-a-multiframe-DICOM-tp2101318p2101318.html > Sent from the ImageJ mailing list archive at Nabble.com. > |
Prashant,
Thanks for your reply. Actually I have installed loci bio formats plug in ImageJ. But I need sample java code which takes a MultiFrame DICOM image as input and uncompressed DICOM or JPEG as output without using ImageJ. Thanks, Phanikanth
|
My requirement is uncompress a multi frame DICOM image and store the uncompressed images into the database.
|
In reply to this post by vmunukutla
Hi Phanikanth,
I think it is very big code.So you have to use bioFormat.jar. It is open source you can use it. And suppose you dont want to use imagej. Then just use bioFormat package and their own classes for opening your Multiframe images. If you want your output in JPEG format. Then with the help of using following code you can do it. The following classes are found on bioFormat.jar package See the documentation. -------------------------------------------------------------------------------------- String id = filepath; ImageReader red = new ImageReader(); red.setId(id); for(int i=0;i<1;i++) { BufferedImage bimg = red.openImage(i); } -------------------------------------------------- As you said you want to pass multiframe images,then you get number of JPEG images as much as your frames. So modify above for loop till frame count and add some line of code for saving buffered Image to JPEG in your Disc. May i know Actually what is your purpose? ----- Original Message ----- From: "vmunukutla" <[hidden email]> To: <[hidden email]> Sent: Friday, January 02, 2009 5:37 PM Subject: Re: Need java code to uncompress a multiframe DICOM > Prashant, > > Thanks for your reply. Actually I have installed loci bio formats plug in > ImageJ. But I need sample java code which takes a MultiFrame DICOM image > as input and uncompressed DICOM or JPEG as output without using ImageJ. > > Thanks, > Phanikanth > > > > prashant-2 wrote: >> >> Hi, >> >> Are you tried with Loci format or BioFormat? >> They are perfect on these things. >> >> I also using bioFormat jar for opening my MultiFrame Dicom images as >> well >> as Single Frame. >> >> >> >> >> >> >> ----- Original Message ----- >> From: "vmunukutla" <[hidden email]> >> To: <[hidden email]> >> Sent: Friday, January 02, 2009 3:23 PM >> Subject: Need java code to uncompress a multiframe DICOM >> >> >>> Hi, >>> >>> I need java code to uncompress multi frame dicom image. >>> >>> Input : Compressed (Multi frame) dicom image (file or byte array). >>> Output : Uncompressed dicom images. >>> >>> Thanks in advance. >>> >>> Regards, >>> Phanikanth >>> -- >>> View this message in context: >>> http://n2.nabble.com/Need-java-code-to-uncompress-a-multiframe-DICOM-tp2101318p2101318.html >>> Sent from the ImageJ mailing list archive at Nabble.com. >>> >> >> > > > > > -- > View this message in context: > http://n2.nabble.com/Need-java-code-to-uncompress-a-multiframe-DICOM-tp2101318p2101590.html > Sent from the ImageJ mailing list archive at Nabble.com. |
In reply to this post by vmunukutla
Prashanth,
Thank very much for your value able suggestion. Actaully my requirement is I will upload a compressed DICOM image from a web page and I have to uncompress the DICOM image and store the umcompressed images into the database. Using bio-formats as a library I am able to get the uncompressed images. But as I am uploading MultiFrame DICOM image from web page, is there any way to pass byte array as param to the IFormatReader.setId() method instead of file path. import java.io.IOException; import loci.formats.ChannelSeparator; import loci.formats.FormatException; import loci.formats.IFormatReader; public class Read_Image { public static void main(String args[]) { String id = "D:\\compressed\\US-PAL-8-10x-echo.dcm"; IFormatReader r = new ChannelSeparator(); try { r.setId(id); int num = r.getImageCount(); System.out.println("num :: "+num); } catch (FormatException exc) { exc.printStackTrace(); } catch (IOException exc) { exc.printStackTrace(); } } } |
Hi Phanikanth,
> But as I am uploading MultiFrame DICOM image from web page, is there any > way > to pass byte array as param to the IFormatReader.setId() method instead of > file path. You can't pass a byte array directly to IFormatReader.setId, but it is quite easy to have Bio-Formats read images from a byte array instead of a file on disk. Here is an example of how to do this: import java.io.IOException; import loci.common.*; import loci.formats.*; public class Test { public static void main(String[] args) throws FormatException, IOException { // the byte array from which to read byte[] bytes = new byte[]; RABytes file = new RABytes(bytes); // Assign a name to the byte array - if you know the file type in advance, // it's a good idea to use the appropriate extension. If you don't know // the file type, don't use an extension, e.g. "file-in-memory". // // This example assumes that the byte array represents DICOM data. Location.mapFile("file-in-memory.dcm", file); // initialize the reader ImageReader reader = new ImageReader(); reader.setId("file-in-memory.dcm"); // read each image for (int i=0; i<reader.getImageCount(); i++) { reader.openImage(i); } reader.close(); } } Note that this requires keeping the entire file in memory, which can be problematic if the file size exceeds the available memory. I have CC'd the LOCI software mailing list - if you have additional questions regarding how to use Bio-Formats as a library, please send them to that list. Instructions on how to subscribe/post to the LOCI software list are available at http://loci.wisc.edu/software/index.html. Regards, -Melissa On Fri, Jan 2, 2009 at 7:26 AM, vmunukutla <[hidden email]> wrote: > Prashanth, > > Thank very much for your value able suggestion. > Actaully my requirement is I will upload a compressed DICOM image from a > web > page and I have to uncompress the DICOM image and store the umcompressed > images into the database. > > Using bio-formats as a library I am able to get the uncompressed images. > > But as I am uploading MultiFrame DICOM image from web page, is there any > way > to pass byte array as param to the IFormatReader.setId() method instead of > file path. > > import java.io.IOException; > import loci.formats.ChannelSeparator; > import loci.formats.FormatException; > import loci.formats.IFormatReader; > public class Read_Image { > public static void main(String args[]) { > > String id = "D:\\compressed\\US-PAL-8-10x-echo.dcm"; > IFormatReader r = new ChannelSeparator(); > try { > r.setId(id); > int num = r.getImageCount(); > System.out.println("num :: "+num); > } > catch (FormatException exc) { > exc.printStackTrace(); > } > catch (IOException exc) { > exc.printStackTrace(); > } > } > } > > > > -- > View this message in context: > http://n2.nabble.com/Need-java-code-to-uncompress-a-multiframe-DICOM-tp2101318p2101777.html > Sent from the ImageJ mailing list archive at Nabble.com. > |
In reply to this post by vmunukutla
Hi Phanikanth,
I hope you got your answer from Melissa. You can contact bioFormat for further help. That is perfect for Multiframe Dicom images. Thanks ----- Original Message ----- From: "vmunukutla" <[hidden email]> To: <[hidden email]> Sent: Friday, January 02, 2009 6:56 PM Subject: Re: Need java code to uncompress a multiframe DICOM > Prashanth, > > Thank very much for your value able suggestion. > Actaully my requirement is I will upload a compressed DICOM image from a > web > page and I have to uncompress the DICOM image and store the umcompressed > images into the database. > > Using bio-formats as a library I am able to get the uncompressed images. > > But as I am uploading MultiFrame DICOM image from web page, is there any > way > to pass byte array as param to the IFormatReader.setId() method instead of > file path. > > import java.io.IOException; > import loci.formats.ChannelSeparator; > import loci.formats.FormatException; > import loci.formats.IFormatReader; > public class Read_Image { > public static void main(String args[]) { > > String id = "D:\\compressed\\US-PAL-8-10x-echo.dcm"; > IFormatReader r = new ChannelSeparator(); > try { > r.setId(id); > int num = r.getImageCount(); > System.out.println("num :: "+num); > } > catch (FormatException exc) { > exc.printStackTrace(); > } > catch (IOException exc) { > exc.printStackTrace(); > } > } > } > > > > -- > View this message in context: > http://n2.nabble.com/Need-java-code-to-uncompress-a-multiframe-DICOM-tp2101318p2101777.html > Sent from the ImageJ mailing list archive at Nabble.com. |
Prashant,
Thank you very much for your support. Thanks to Melissa also. Yes, I got the solution.Did exactly what Melissa said. Thanks, Phanikanth
|
most welcome
----- Original Message ----- From: "vmunukutla" <[hidden email]> To: <[hidden email]> Sent: Monday, January 05, 2009 11:48 AM Subject: Re: Need java code to uncompress a multiframe DICOM > Prashant, > > Thank you very much for your support. Thanks to Melissa also. > Yes, I got the solution.Did exactly what Melissa said. > > > Thanks, > Phanikanth > > > prashant-2 wrote: >> >> Hi Phanikanth, >> >> I hope you got your answer from Melissa. >> You can contact bioFormat for further help. >> That is perfect for Multiframe Dicom images. >> >> Thanks >> >> >> >> >> >> ----- Original Message ----- >> From: "vmunukutla" <[hidden email]> >> To: <[hidden email]> >> Sent: Friday, January 02, 2009 6:56 PM >> Subject: Re: Need java code to uncompress a multiframe DICOM >> >> >>> Prashanth, >>> >>> Thank very much for your value able suggestion. >>> Actaully my requirement is I will upload a compressed DICOM image from a >>> web >>> page and I have to uncompress the DICOM image and store the umcompressed >>> images into the database. >>> >>> Using bio-formats as a library I am able to get the uncompressed images. >>> >>> But as I am uploading MultiFrame DICOM image from web page, is there any >>> way >>> to pass byte array as param to the IFormatReader.setId() method instead >>> of >>> file path. >>> >>> import java.io.IOException; >>> import loci.formats.ChannelSeparator; >>> import loci.formats.FormatException; >>> import loci.formats.IFormatReader; >>> public class Read_Image { >>> public static void main(String args[]) { >>> >>> String id = "D:\\compressed\\US-PAL-8-10x-echo.dcm"; >>> IFormatReader r = new ChannelSeparator(); >>> try { >>> r.setId(id); >>> int num = r.getImageCount(); >>> System.out.println("num :: "+num); >>> } >>> catch (FormatException exc) { >>> exc.printStackTrace(); >>> } >>> catch (IOException exc) { >>> exc.printStackTrace(); >>> } >>> } >>> } >>> >>> >>> >>> -- >>> View this message in context: >>> http://n2.nabble.com/Need-java-code-to-uncompress-a-multiframe-DICOM-tp2101318p2101777.html >>> Sent from the ImageJ mailing list archive at Nabble.com. >> >> > > -- > View this message in context: > http://n2.nabble.com/Need-java-code-to-uncompress-a-multiframe-DICOM-tp2101318p2111875.html > Sent from the ImageJ mailing list archive at Nabble.com. > |
Free forum by Nabble | Edit this page |