[ITK-users] QVtkWidget beginner questions
Matt McCormick
matt.mccormick at kitware.com
Thu Sep 1 09:45:56 EDT 2016
Hi Ibraheem,
On Thu, Sep 1, 2016 at 4:20 AM, Ibraheem via Insight-users
<insight-users at itk.org> wrote:
> Many thanks Matt for your response and answers.
>
> Matt McCormick-3 wrote
>>> 1- Is there a way to filter and write all the images at once instead of
>>> using the for loop?
>> To write to an image series in general, there is an
>> itk::ImageSeriesWriter.
>
> I tried this:
> reader->SetFileNames(inputNames->GetInputFileNames() ); // get all
> slices
> reader->Update();
> // filtering : get threshold
> filterThresh->SetInput( reader->GetOutput() );
> QString thVals=ui->ThVal->text();
> int ut= thVals.toInt() ;
> filterThresh->ThresholdAbove(ut);
> filterThresh->SetOutsideValue(0);
> filterThresh->Update();
> // Convert to VTK image using ImageToVTKImageFilter
> vtkImgF->SetInput(filterThresh->GetOutput (sliceID));
> but it does not work. With adding sliceID the program crash. Without it, I
> get only the first slice. How can i get a specific slice from the filter
> output?
Briefly reviewing the code, a few suggestions come to mind:
- Set all filenames to the ImageSeriesReader (instead of just one)
- Call ->UpdateLargestPossibleRegion() at the end of the pipeline
instead of just ->Update() when multiple pipeline calls are made to
ensure the LargestPossibleRegion is reset in the pipeline.
- Check out
https://itk.org/Doxygen/html/Examples_2IO_2DicomSeriesReadImageWrite2_8cxx-example.html
for another example.
> You are right. About question four, isn't it possible to create an itk image
> from a collected voxels (this is the part I don't know) then convert it to
> vtk image like I did in the example?
Yes! More information and tips can be found here:
https://blog.kitware.com/how-to-connect-itk-and-vtk-pipelines/
https://itk.org/ITKExamples/src/Bridge/VtkGlue/ConvertAnitkImageTovtkImageData/Documentation.html
Hope this helps,
Matt
More information about the Insight-users
mailing list