[ITK] [ITK-users] Export specific frame/slice of multiframe dicom file: ExtractSliceImageFilter?

Marcos fotosentido at gmail.com
Tue Sep 1 15:19:32 EDT 2015


I'm sorry, obviously it's:


typedef itk::ImageFileWriter<FrameImageType> WriterType;

and

writer->SetInput(extracter->GetOutput());


It's working.

Just a thing: size gives me {512, 512, 0} but the image output is 998x881.


It's weird, isn't it?


Thank you.


2015-09-01 20:41 GMT+02:00 Marcos <fotosentido at gmail.com>:

> Hmmm, yes, that's the idea.
>
> I was trying, and I think I got it, but something is wrong connecting its
> output to the input of another filter:
>
> void Exporter::exportOriginal(QString fileName, ImageType::Pointer image, int frame)
>
> {
>
>     typedef itk::ImageFileWriter<ImageType> WriterType;
>
>     WriterType::Pointer writer = WriterType::New();
>
>     writer->SetFileName(fileName.toStdString().c_str());
>
>     writer->SetInput(image);
>
>
>     ImageType::RegionType inputRegion = image->GetLargestPossibleRegion();
>
>     ImageType::IndexType index = inputRegion.GetIndex();
>
>     ImageType::SizeType size = inputRegion.GetSize();
>
>
>     index[0] = 0;
>
>     index[1] = 0;
>
>     index[2] = frame;
>
>     size[2] = 0;
>
>
>     ImageType::RegionType outputRegion;
>
>     outputRegion.SetIndex(index);
>
>     outputRegion.SetSize(size);
>
>
>     typedef itk::Testing::ExtractSliceImageFilter<ImageType, FrameImageType> ExtractType;
>
>     ExtractType::Pointer extracter = ExtractType::New();
>
>     extracter->SetExtractionRegion(outputRegion);
>
>
>     writer->GetInput(extracter->GetOutput());
>
>     try
>
>     {
>
>         writer->Update();
>
>     }
>
>     catch (itk::ExceptionObject &ex)
>
>     {
>
>         std:cerr << ex << std::endl;
>
>     }
>
> }
>
>
> Trying to compile, it gives me:
>
>
> "error: C2664: 'const itk::Image<UTILS::PixelType,3> *itk::ImageFileWriter<UTILS::ImageType>::GetInput(unsigned int)' : cannot convert argument 1 from 'itk::Image<UTILS::PixelType,2> *' to 'unsigned int'
> There is no context in which this conversion is possible"
>
>
> Well, where is the unsigned int?? The input and output format of ExtractSliceImageFilter were unsigned short, and after seeing this I changed to unsigned int, with same result.
>
>
> Anyone seeing the problem? Cause I can't understand the error.
>
>
> Thank you.
>
>
> 2015-09-01 10:31 GMT+02:00 Timothee Evain <tevain at telecom-paristech.fr>:
>
>> Hello Marcos,
>>
>> You can extract one slice from your 3D data with itk::ExtractImageFilter
>> You have to specify the region you want to get as indicated here
>> http://www.itk.org/Doxygen/html/classitk_1_1ExtractImageFilter.html
>> More precisely, you have to indicate the index of the slice you want and
>> set the third dimension size to 0.
>> For example, saying you have an image 250x250x250 and you want the 89th
>> slice you have to set:
>> RegionSize = {250,250,0}
>> RegionIndex = {0,0,89}
>>
>> The filter return a 2D image when you collapse the third dimension.
>>
>> I think this can be what you want ?
>>
>> Tim
>>
>> ----- Mail original -----
>> De: "Marcos" <fotosentido at gmail.com>
>> À: insight-users at itk.org
>> Envoyé: Mardi 1 Septembre 2015 09:45:00
>> Objet: Re: [ITK] [ITK-users] Export specific frame/slice of multiframe
>> dicom   file: ExtractSliceImageFilter?
>>
>> Hi,
>>
>> the input of vtkJPEGWriter:
>>
>> template < class T >
>> void Exporter :: exportImage ( QString fileName , QVTKWidget * widget )
>> {
>> vtkWindowToImageFilter * filter = vtkWindowToImageFilter :: New ();
>> filter -> SetInput ( widget -> GetRenderWindow ());
>>
>> vtkSmartPointer < T > writer = vtkSmartPointer < T >:: New ();
>> writer -> SetFileName ( fileName . toStdString (). c_str ());
>> writer -> SetInputConnection ( filter -> GetOutputPort ());
>>
>> writer -> Write ();
>> }
>>
>> T can be an vtkJPEGWriter, vtkPNGWriter, etc.
>> I set the slice with vtkImageViewer2::GetSlice()
>> But this depends on the vtk renderwindow, and its size,...
>>
>> That's why I need to do it with ITK, unless I can export the original
>> frame with VTK.
>>
>> Thank you.
>>
>> 2015-09-01 1:16 GMT+02:00 Siavash Khallaghi < siavashk at ece.ubc.ca > :
>>
>>
>> Hi Marcos,
>>
>> How do you set the input of your vtkJPEGWriter?
>>
>> Siavash
>>
>>
>>
>> --
>> View this message in context:
>> http://itk-users.7.n7.nabble.com/ITK-users-Export-specific-frame-slice-of-multiframe-dicom-file-ExtractSliceImageFilter-tp36081p36084.html
>> Sent from the ITK - Users mailing list archive at Nabble.com.
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/insight-users
>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/insight-users
>>
>> _______________________________________________
>> Community mailing list
>> Community at itk.org
>> http://public.kitware.com/mailman/listinfo/community
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150901/4ddf5fd6/attachment-0001.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list