<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Greetings, <BR>
<BR>
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? <BR>
<BR>
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. <BR>
<BR>
Vik<BR>
<BR>> ------------------------------<BR>> <BR>> Good morning,<BR>> <BR>> 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 <BR>> process... Thank you for your help. <BR>> Vik<BR>> <BR>> Code: <BR>> <BR>> #include "itkImage.h"#include "itkImageFileReader.h"#include "itkImageFileWriter.h"#include "itkResampleImageFilter.h"#include "itkLinearInterpolateImageFunction.h"<BR>> <BR>> 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; }<BR>> <BR>> const unsigned int Dimension = 3; typedef unsigned short PixelType;<BR>> <BR>> typedef itk::Image< PixelType, Dimension > FixedImageType; typedef itk::Image< PixelType, Dimension > MovingImageType; typedef itk::Image< PixelType, Dimension > OutputImageType;<BR>> typedef itk::ImageFileReader< FixedImageType > ReaderType; typedef itk::ImageFileReader< MovingImageType > ReaderType; typedef itk::ImageFileWriter< OutputImageType > WriterType;<BR>> <BR>> ReaderType::Pointer fixedreader = ReaderType::New(); ReaderType::Pointer movingreader = ReaderType::New(); WriterType::Pointer writer = WriterType::New();<BR>> fixedreader->SetFileName( argv[1] ); movingreader->SetFileName( argv[2] ); writer->SetFileName( "Resampledcontours.mhd" );<BR>> fixedreader->Update();<BR>> <BR>> 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 );<BR>> <BR>> typedef itk::LinearInterpolateImageFunction< MovingImageType, double > InterpolatorType; InterpolatorType::Pointer interpolator = InterpolatorType::New(); filter->SetInterpolator( interpolator );<BR>> filter->SetDefaultPixelValue( 0 );<BR>> <BR>> double spacing[ Dimension ];<BR>> spacing[0] = fixedreader->GetOutput()->GetSpacing()[0]; spacing[1] = fixedreader->GetOutput()->GetSpacing()[1]; spacing[2] = fixedreader->GetOutput()->GetSpacing()[2]; filter->SetOutputSpacing( spacing );<BR>> <BR>> double origin[ Dimension ]; origin[0] = fixedreader->GetOutput()->GetOrigin()[0]; origin[1] = fixedreader->GetOutput()->GetOrigin()[1]; origin[2] = fixedreader->GetOutput()->GetOrigin()[2]; filter->SetOutputOrigin( origin );<BR>> <BR>> filter->SetSize( fixedreader->GetOutput()->GetLargestPossibleRegion().GetSize() );<BR>> <BR>> 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; }<BR>> return EXIT_SUCCESS;}<BR>> <BR><BR><br /><hr />Want to do more with Windows Live? Learn “10 hidden secrets” from Jamie. <a href='http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008' target='_new'>Learn Now</a></body>
</html>