[Insight-users] Resampling/rescaling a dataset

Vikren Sarkar vikmonster at hotmail.com
Fri Sep 5 18:51:23 EDT 2008


Greetings, 
 
I found the flaw in my logic regarding my question (below) with regards to image resampling with different interpolators. I guess what I really needed was image rescaling instead of resampling. I do have a follow-up question though. As a reminder, I have an image that contains contour information for a CT dataset. The voxels where the contour is present have a value of 1000 while the other voxels have zero. Thus, if you look at different slices, you see an outline of an object. Now I have a different image set of the same object except that the second image set is different somehow - different number of voxels and/or different voxel dimension and/or different origin. I want to resample the original contour to see where it should lie on the second set. I thought of doing a resample but I realize that some of the contours do not end up continuous necessarily. So maybe I need to rescale? But what about the origin being in a different location? 
 
As an alternative, I thought I could fill each contour to have a "blob" instead of an outline. Then I could resample and maybe use an edge detection to get the contour outline. Does ITK have a function to fill in an object given the outline? Any ideas and or suggestions would be very welcome. Thank you. 
 
Vik
> ------------------------------> > Good morning,> > I am trying to resample contours and am running into a bit of a problem. The method I am using is as follows: I create a matrix of zeros which is as big as the image set I am looking at. If a contour is present on a particular voxel, I set that voxel's value to 1000. I then use the code below to resample the matrix. The first case I tried was to scale all axial images by 1/2 (keeping offsets constant). When I use the NearestNeighborInterpolateImageFunction, I get the results I expect, with the occasional breaks in the contour. When I switch to the LinearInterpolateImageFunction, my instincts tell me I should get the same contour as before, except with the value of 500 instead of 1000. However, I get the exact same results as with the nearest neighbor method. Same for the BSplineInterpolateImageFunction, which incidentally does take much longer to run. I woul dvery much appreciate it if someone could point me to the mistake I am making, either with the code or with my thought > process... Thank you for your help. > Vik> > Code: > > #include "itkImage.h"#include "itkImageFileReader.h"#include "itkImageFileWriter.h"#include "itkResampleImageFilter.h"#include "itkLinearInterpolateImageFunction.h"> > int main( int argc, char * argv[] ){ if( argc < 3 ) { std::cerr << "Usage: " << std::endl; std::cerr << argv[0] << " Resampleto.mhd currentcontour.mhd " << std::endl; return EXIT_FAILURE; }> > const unsigned int Dimension = 3; typedef unsigned short PixelType;> > typedef itk::Image< PixelType, Dimension > FixedImageType; typedef itk::Image< PixelType, Dimension > MovingImageType; typedef itk::Image< PixelType, Dimension > OutputImageType;> typedef itk::ImageFileReader< FixedImageType > ReaderType; typedef itk::ImageFileReader< MovingImageType > ReaderType; typedef itk::ImageFileWriter< OutputImageType > WriterType;> > ReaderType::Pointer fixedreader = ReaderType::New(); ReaderType::Pointer movingreader = ReaderType::New(); WriterType::Pointer writer = WriterType::New();> fixedreader->SetFileName( argv[1] ); movingreader->SetFileName( argv[2] ); writer->SetFileName( "Resampledcontours.mhd" );> fixedreader->Update();> > typedef itk::ResampleImageFilter< MovingImageType, OutputImageType > FilterType; FilterType::Pointer filter = FilterType::New(); typedef itk::IdentityTransform< double, Dimension > TransformType; TransformType::Pointer transform = TransformType::New(); transform->SetIdentity(); filter->SetTransform( transform );> > typedef itk::LinearInterpolateImageFunction< MovingImageType, double > InterpolatorType; InterpolatorType::Pointer interpolator = InterpolatorType::New(); filter->SetInterpolator( interpolator );> filter->SetDefaultPixelValue( 0 );> > double spacing[ Dimension ];> spacing[0] = fixedreader->GetOutput()->GetSpacing()[0]; spacing[1] = fixedreader->GetOutput()->GetSpacing()[1]; spacing[2] = fixedreader->GetOutput()->GetSpacing()[2]; filter->SetOutputSpacing( spacing );> > double origin[ Dimension ]; origin[0] = fixedreader->GetOutput()->GetOrigin()[0]; origin[1] = fixedreader->GetOutput()->GetOrigin()[1]; origin[2] = fixedreader->GetOutput()->GetOrigin()[2]; filter->SetOutputOrigin( origin );> > filter->SetSize( fixedreader->GetOutput()->GetLargestPossibleRegion().GetSize() );> > filter->SetInput( movingreader->GetOutput() ); writer->SetInput( filter->GetOutput() ); try { writer->Update(); } catch( itk::ExceptionObject & excep ) { std::cerr << "Exception catched !" << std::endl; std::cerr << excep << std::endl; }> return EXIT_SUCCESS;}> 
_________________________________________________________________
Want to do more with Windows Live? Learn “10 hidden secrets” from Jamie.
http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080905/ee1da112/attachment-0001.htm>


More information about the Insight-users mailing list