[Insight-users] ImageAdaptor and Regions

Luis Ibanez luis.ibanez at kitware.com
Sun Aug 8 12:50:02 EDT 2004


Hi Nick,

Thanks for doing the experiments and
letting us know of the results.

 From your report, it seems that the
ImageAdaptor is failing to propagate
the Update() messages of the pipeline.

We were able to reproduce the error that
you reported and created a bug entry in
the bugTracker database.

It got the Bug Id # 1035

http://www.itk.org/Bug/bug.php?op=show&bugid=1035&pos=0

If you want to get updates on the status
of this bug, please register your email
with the bug tracker, go to this bug number
and put your email in the "add CC" box entry
toward the right.

We will try to fix this before the release 1.8,
but it may slip out depending on other bug
priorities.



   Thanks



      Luis



--------------------
Nick Arini wrote:
> Luis,
> 
> I ran the experiments you suggested with the following results:
> 
> Thanks,
> Nick.
> 
> Luis Ibanez wrote:
> 
>>
>> Hi Nick,
>>
>> Please do the two following experiments:
>>
>> 1) Instead of calling Update() in the resampler filter
>>    call UpdateLargestPossibleRegion().
> 
> 
> RESULT:  This caused exactly the same behaviour as previously (i.e. 
> exception still thrown).
> 
>>
>> 2) Before calling Update() in the resampler filter, call
>>    Update() directly on the reader.
>>
> RESULT: This fixed the problem and led to the program giving the 
> expected and desired results (i.e. image loaded and rescaled correctly).
> 
>>
>> Let us know what happens on each cases, that
>> will help us localize the eventual problem.
>>
>>
>>   Thanks
>>
>>
>>     Luis
>>
>>
>> ---------------------
>> Nick Arini wrote:
>>
>>> Dear Insight users,
>>>
>>> I am trying to use an image adapter to get and rescale the individual 
>>> channels of an RGB image in a similar way to
>>> Examples/DataRepresentation/Image/ImageAdaptor2.cxx.
>>>
>>> I then want to use an image iterator on the resulting images to 
>>> access the pixel values of the individual channels. I have 
>>> encountered a problem with defining a region (I want the whole image 
>>> here) for input to the iterator. This works just fine until I added 
>>> the ImageAdaptor stuff. I caught the exception and it tells me I am 
>>> requesting a region outside the largest region but as I want the 
>>> whole image and it stays the same size throughout I dont know why I 
>>> am getting this exception. The message and the code snippet are 
>>> below. Can anyone enlighten me as to what I have done wrong?
>>>
>>> Thanks and best regards,
>>>
>>> Nick
>>>
>>> <begin exception message>
>>>
>>>  itk::ExceptionObject (0xbfe3f9e0)
>>>  Location: "ImageAdaptor::PropagateRequestedRegion()"
>>>  File: /home/nicha/ITK_source/Insight/Code/Common/itkDataObject.cxx
>>>  Line: 397
>>>  Description: Requested region is (at least partially) outside the 
>>> largest possible region.
>>>
>>> <end exception message>
>>>
>>>
>>>
>>> <begin code>
>>>
>>>    typedef  float                                                  
>>> ChannelPixelType;
>>>    typedef  itk::RGBPixel< ChannelPixelType >   RGBPixelType;
>>>
>>>
>>>    // We will need to use an adapter to make the RGB image look like 
>>> a scalar image for the rescaling
>>>    typedef itk::RedPixelAccessor< ChannelPixelType >::InternalType 
>>> InputPixelType;
>>>      typedef itk::Image< InputPixelType,  2 >  ImageType;
>>>    typedef itk::ImageAdaptor< ImageType, itk::RedPixelAccessor< 
>>> ChannelPixelType > > ImageAdaptorType;
>>>
>>>    ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
>>>
>>>
>>>    typedef itk::ImageFileReader< ImageType >  ReaderType;
>>>    ReaderType::Pointer reader = ReaderType::New();
>>>    reader->SetFileName( filename );
>>>
>>>
>>>    adaptor->SetImage( reader->GetOutput() );
>>>
>>>
>>>    typedef itk::Image< ChannelPixelType > OutputImageType; // the red 
>>> channel image type
>>>
>>>    // Do some image rescaling here
>>>    typedef itk::RescaleIntensityImageFilter< ImageAdaptorType, 
>>> OutputImageType >  RescalerType;
>>>    RescalerType::Pointer rescaler = RescalerType::New();
>>>    rescaler->SetInput( adaptor );
>>>       rescaler->SetOutputMinimum( 0 );
>>>    rescaler->SetOutputMaximum( 255 );
>>>
>>>    OutputImageType::Pointer image = rescaler->GetOutput();
>>>  
>>>    try
>>>      {
>>>        rescaler->Update();
>>>      }
>>>    catch( itk::ExceptionObject exp )
>>>      {
>>>        std::cout << exp << std::endl;
>>>      }
>>>      // now get the region associated with the image
>>>    OutputImageType::RegionType region = 
>>> image->GetLargestPossibleRegion();
>>>
>>>
>>>    // And the image dimensions
>>>   Output ImageType::RegionType::SizeValueType width = region.GetSize(0);
>>>   OutputImageType::RegionType::SizeValueType height = region.GetSize(1);
>>>
>>>    // define and construct a simple image iterator from an 
>>> itk::Image       typedef itk::ImageRegionConstIterator< 
>>> OutputImageType > ConstIteratorType;
>>>    ConstIteratorType constIterator( image, region );
>>>
>>>    // Use the iterator in a loop
>>>    for( constIterator.GoToBegin(); !constIterator.IsAtEnd(); 
>>> ++constIterator )
>>>      {
>>>         float pix  =  constIterator.Get();
>>>      }
>>>
>>>
>>> <end code>
>>>
>>> _______________________________________________
>>> Insight-users mailing list
>>> Insight-users at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>>
>>
>>
>>
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 






More information about the Insight-users mailing list