[Insight-users] [insight-users] ConnectedThresholdImageFilter - Memory allocation

Luis Ibanez luis.ibanez at kitware.com
Sat Mar 6 20:14:39 EST 2010


Hi Juan Carlos,


                 Welcome to ITK !


Thanks for posting your code.



We need some additional information.

1) What is the pixel type of "InternalImageType"

2) What is the size of the "huge" input image ?
    (both in pixels and in bytes)

3) How much RAM do you have in your computer

4) What is your operating system ?

5) Is it a 64 bits operating system ?

6) What is your compiler ?
    Are you compiling for 64 bits ?


If the InternalImageType is not one with a
"unsigned char" pixel type, then you will
save some memory if your do:

typedef  unsigned char  MaskPixelType;
typedef  itk::Image< MaskPixelType, Dimension > MaskImageType

and then replace the line:

typedef itk::ConnectedThresholdImageFilter<
        InternalImageType,
        InternalImageType > ConnectedFilterType;


with

typedef itk::ConnectedThresholdImageFilter<
        InternalImageType,
        MaskImageType > ConnectedFilterType;



This region growing filter will produce a binary image
as output. Therefore, using as output, any pixel type
different from "unsigned char" will be a waste of RAM.


     Regards,


           Luis


------------------------------------------------------------------------------------------
On Thu, Mar 4, 2010 at 4:56 AM, Juan Carlos Prieto
<juanprietob at gmail.com> wrote:
> Hello Insight Users
>
> I just started ITK and I have a problem using the
> ConnectedThresholdImageFilter, I have a big image volume as input and then
> when performing the update there is a memory allocation problem.
>
> Can some body help me with the procedure on how to execute the filter by
> regions (if possible)
>
> A part of my code:
>
> typedef ITKToVTKImageImport::itkImageType InternalImageType;
>         InternalImageType* image;
>         InternalImageType* imageout;
>         typedef itk::ConnectedThresholdImageFilter< InternalImageType,
> InternalImageType > ConnectedFilterType;
>         ConnectedFilterType::Pointer connectedThreshold;
>         InternalImageType::IndexType  index;
>         itk::Vector<TypeImage, DIM> spc;
>
>         image = this->getITKImage();    //Huge image input
>         connectedThreshold = ConnectedFilterType::New();
>         connectedThreshold->SetInput( image );
>         connectedThreshold->SetLower(  *_min  );
>         connectedThreshold->SetUpper(  *_max  );
>         spc = image->GetSpacing();
>
>         index[0] = (*_point)[0]*spc[0];
>         index[1] = (*_point)[1]*spc[1];
>         index[2] = (*_point)[2]*spc[2];
>
>         connectedThreshold->SetSeed( index );
>         connectedThreshold->SetReplaceValue( 255 );
>         connectedThreshold->Update();                      //Throws
> exception indicating the memory allocation problem
>         imageout = connectedThreshold->GetOutput();
>
>
>
> Thank you very much
>
> _____________________________________
> 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