[Insight-users] Cut ROI from a image by giving the mask

Luis Ibanez luis.ibanez at kitware.com
Sun Jan 24 10:20:16 EST 2010


Hi  Xi,


Your intuition is right in both points.


1) The proper way to walk through the images
     is to use ITK iterators.  You will find them
     described in detail in the ITK Software Guide

     http://www.itk.org/ItkSoftwareGuide.pdf

           in Chapter 11, pdf-page 733.

     You will find source code examples in
     the directory:

           Insight/Examples/Iterators


2) For the operation itself:

    You can simply use the MaskImageFilter
http://www.itk.org/Doxygen/html/classitk_1_1MaskImageFilter.html


   Regards,


          Luis



-----------------------------------------------------------------------
2010/1/23 Xi LIANG <liangxi1986317 at hotmail.com>:
> Dear all,
>
> I am trying to cut a ROI from the fixed image based on the mask of ROI. Both
> fixed image and ROI mask are in the same format 128 X 128 X 124 as input. I
> can cut the image properly by using the following code (only the core part,
> and the whole code are attached. I have two questions here. Firstly, I just
> feel this is not the right way to do, there should be some function to do
> this. Secondly, I dont know how to get the total index number in one
> dimension, and I manually put the 128, 128, 124 into the code.
>
>   for(i = 0; i < 128; i++)
>   {
>  std::cerr << i << std::endl;
>  for(j = 0; j < 128; j++)
>  {
>  for(k = 0; k < 124; k++)
>  {
>  pixelLocation[0] = i;
>  pixelLocation[1] = j;
>  pixelLocation[2] = k;
>  inputPixelValue = fixedImage->GetPixel(pixelLocation);
>  maskPixelValue = maskImage->GetPixel(pixelLocation);
>  pixelValue = inputPixelValue * maskPixelValue;
>  outputImage->SetPixel( pixelLocation, pixelValue);
>  }
>  }
>   }
>
> --------------------------------
> Xi Liang
>
> 梁茜
> --------------------------------
>
>
>
> ________________________________
> Windows Live: Make it easier for your friends to see what you're up to on
> Facebook.
> _____________________________________
> 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.html
>
> 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://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list