DICOM Roi to Tiff

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

DICOM Roi to Tiff

Guido Lütke Wöstmann
Hi,

what I want to do is:

Open a DICOM-File, create a ROI and save only this ROI as a TIFF-Image.

Doing this by using the GUI of ImageJ is simple and not the Problem.
My Problem is:

I want to use the ImageJ-API. I tried to use Code like this:

ShortProcessor sp = new ShortProcessor(width, height);
roi.drawPixels(sp);

ImagePlus ip = new ImagePlus("", sp);
FileSaver fs = new FileSaver(ip);

fs.saveAsTiff();

But I can't open the resulting Tiff-Image. Whats wrong with this Code?
Do I have to convert the DICOM-Image before saving?

Thanks for help,

Guido
Reply | Threaded
Open this post in threaded view
|

Re: DICOM Roi to Tiff

Johannes Hermen
> Open a DICOM-File, create a ROI and save only this ROI as a TIFF-Image.

Why not just open the DICOM to an ImagePlus, then set the ROI to the
ImagePlus and do a dublicate() to the ImagePlus.
You will get a new ImagePlus with only the region of the ROI. Then just
save this ImagePlus as a TIFF.

hope this does the job.
        Johannes


-----------------------------------------------------------------
Johannes Hermen  -  Ingenieur de Recherche
[hidden email]
-----------------------------------------------------------------
CRP Henri Tudor  http://www.santec.tudor.lu
29, Avenue John F. Kennedy
L-1855 Luxembourg
-----------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: DICOM Roi to Tiff

Guido Lütke Wöstmann
Johannes Hermen schrieb:
>> Open a DICOM-File, create a ROI and save only this ROI as a TIFF-Image.
>
> Why not just open the DICOM to an ImagePlus, then set the ROI to the
> ImagePlus and do a dublicate() to the ImagePlus.

I can't find a du(p/b)licate()-Method in the ImagePlus-Class!?

> You will get a new ImagePlus with only the region of the ROI. Then just
> save this ImagePlus as a TIFF.
>
> hope this does the job.
>         Johannes
>
>
> -----------------------------------------------------------------
> Johannes Hermen  -  Ingenieur de Recherche
> [hidden email]
> -----------------------------------------------------------------
> CRP Henri Tudor  http://www.santec.tudor.lu
> 29, Avenue John F. Kennedy
> L-1855 Luxembourg
> -----------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: DICOM Roi to Tiff

Johannes Hermen
> > Why not just open the DICOM to an ImagePlus, then set the ROI to the
> > ImagePlus and do a dublicate() to the ImagePlus.
>
> I can't find a du(p/b)licate()-Method in the ImagePlus-Class!?

sorry, my fault.

imagePlus.getProcessor().dublicate();

-----------------------------------------------------------------
Johannes Hermen  -  Ingenieur de Recherche
[hidden email]
-----------------------------------------------------------------
CRP Henri Tudor  http://www.santec.tudor.lu
29, Avenue John F. Kennedy
L-1855 Luxembourg
-----------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: DICOM Roi to Tiff

Guido Lütke Wöstmann
Johannes Hermen schrieb:
>>> Why not just open the DICOM to an ImagePlus, then set the ROI to the
>>> ImagePlus and do a dublicate() to the ImagePlus.
>> I can't find a du(p/b)licate()-Method in the ImagePlus-Class!?
>
> sorry, my fault.
>
> imagePlus.getProcessor().dublicate();

Thank you for your quick help, but:

imagePlus.getProcessor().duplicate()

returns an ImageProcessor and saving this one saves the WHOLE Image ;-)
But I can display the resulting Image, so your Code is an Improvement.

>
> -----------------------------------------------------------------
> Johannes Hermen  -  Ingenieur de Recherche
> [hidden email]
> -----------------------------------------------------------------
> CRP Henri Tudor  http://www.santec.tudor.lu
> 29, Avenue John F. Kennedy
> L-1855 Luxembourg
> -----------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: DICOM Roi to Tiff

Johannes Hermen
last try for today:

        ImagePlus ip = new ImagePlus("path_to_my_image");
        ImageProcessor ipro = ip.getProcessor();
        ipro.setRoi(100,100, 100, 100);
        ipro = ipro.crop();
        ip = new ImagePlus ("new image", ipro.duplicate());
        //ip.show();
        // save to tiff


-----------------------------------------------------------------
Johannes Hermen  -  Ingenieur de Recherche
[hidden email]
-----------------------------------------------------------------
CRP Henri Tudor  http://www.santec.tudor.lu
29, Avenue John F. Kennedy
L-1855 Luxembourg
-----------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: DICOM Roi to Tiff

Guido Lütke Wöstmann
The same what I did:


ImageProcessor imPro = this.getProcessor().crop();
ImagePlus ip2 = new ImagePlus("title",imPro);
FileSaver fs2 = new FileSaver(ip2);
fs2.saveAsTiff("path.tif");

with an given Image and Roi (your first two Lines).

Thank you for your Help!!

Johannes Hermen schrieb:

> last try for today:
>
>         ImagePlus ip = new ImagePlus("path_to_my_image");
>         ImageProcessor ipro = ip.getProcessor();
>         ipro.setRoi(100,100, 100, 100);
>         ipro = ipro.crop();
>         ip = new ImagePlus ("new image", ipro.duplicate());
>         //ip.show();
>         // save to tiff
>
>
> -----------------------------------------------------------------
> Johannes Hermen  -  Ingenieur de Recherche
> [hidden email]
> -----------------------------------------------------------------
> CRP Henri Tudor  http://www.santec.tudor.lu
> 29, Avenue John F. Kennedy
> L-1855 Luxembourg
> -----------------------------------------------------------------