[Insight-users] transform inverse?

Lars Hegenbart lars.hegenbart at hs.fzk.de
Mon Oct 6 09:50:21 EDT 2008


Dear ITK-community,
I am defining an affine transform with [2, 0, 0,  0, 2, 0,  0, 0, 2,   
0, 0, 0], basically a stretch of factor 2 in all 3 dimensions. I want  
to apply it to an input image to create an output image with same  
parameters (spacing, etc.). I end up getting an output which is scaled  
by a factor of 0.5 instead of 2. If I choose 0.5 in the diagonal of  
the matrix of the affine transform, I end up with the wanted result.  
It seems somehow to be inverted. What's wrong or is that normal?
Thanks for any hints.
Best regards
Lars

PS: here some relevant code parts:

	typedef itk::Image< unsigned char, Dimension > InputImageType;
	typedef itk::Image< unsigned char, Dimension > OutputImageType;
	InputImageType::Pointer i_image;
	OutputImageType::Pointer o_image;

	InputImageType::SpacingType spacing;
	spacing[0] = 6; //spacing along x
	spacing[1] = 6; //spacing along y
	spacing[2] = 6; //spacing along z
	i_image->SetSpacing(spacing);
	InputImageType::PointType origin;
	origin[0] = 0;
	origin[1] = 0;
	origin[2] = 0;
	i_image->SetOrigin(origin);
	InputImageType::SizeType size;
	size[0] = 100; // size along x
	size[1] = 100; // size along y
	size[2] = 100; // size along z

	typedef itk::AffineTransform< double, Dimension >   			    
TransformType;	
	TransformType::Pointer transform;

	typedef TransformType::ParametersType     ParametersType;
	const unsigned int numberOfParameters = transform- 
 >GetNumberOfParameters();
     	ParametersType parameters( numberOfParameters );
     	parameters_affine[ 0]=  2;
     	parameters_affine[ 1]=  0;
     	parameters_affine[ 2]=  0;
     	parameters_affine[ 3]=  0;
     	parameters_affine[ 4]=  2;
     	parameters_affine[ 5]=  0;
     	parameters_affine[ 6]=  0;
     	parameters_affine[ 7]=  0;
     	parameters_affine[ 8]=  2;
     	parameters_affine[ 9]=  0;
     	parameters_affine[10]= 0;
     	parameters_affine[11]= 0;
     	transform->SetParameters( parameters);

	typedef itk::ResampleImageFilter< InputImageType, OutputImageType >   
FilterType;
	FilterType::Pointer filter = FilterType::New();
	filter->SetTransform(transform);

	typedef itk::NearestNeighborInterpolateImageFunction< InputImageType,  
double > InterpolatorType;
	InterpolatorType::Pointer interpolator = InterpolatorType::New();
	filter->SetInterpolator(interpolator);
	filter->SetDefaultPixelValue(0);

	filter->SetOutputSpacing(i_image->GetSpacing()); // same spacing like  
InputImage
	filter->SetOutputOrigin(i_image->GetOrigin()); // same like InputImage
	filter->SetSize(size); // same like InputImage
	filter->SetInput(i_image);
	
	o_image = filter->GetOutput();



Am 06.10.2008 um 15:17 schrieb Luis Ibanez:

>
> Hi Zhihong,
>
> Do you want to convert the grayscale image to RGB by simply  
> duplicating
> the pixel values in all the three channels ?
>
> Or do you want to use a Lookup table in order to generate 'false'
> color ?
>
> If you want the second one, then you may want to look a the combined
> use of the classes:
>
> #include "itkUnaryFunctorImageFilter.h"
> #include "itkScalarToRGBPixelFunctor.h"
>
> as illustrated in
>
>  Insight/Examples/Segmentation/WatershedSegmentation1.cxx
>
>
> Regards,
>
>
>   Luis
>
>
> -----------------------
> zhihong hu wrote:
>> Hi Luis,
>> I know there is an image adaptor in ITK, which can take out one  
>> component (such as green channel) from RGB images. I am wondering  
>> if there is some function that can convert gray value images to RGB  
>> images.
>> Thank you very much.
>> Zhihong
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users

-------------------------------------------
Dipl.-Ing. (FH) Lars Hegenbart

Forschungszentrum Karlsruhe GmbH
in der Helmholtz-Gemeinschaft
Abteilung HS/KES
Hermann-von-Helmholtz-Platz 1
76344 Eggenstein-Leopoldshafen
Germany

Tel. +49-7247-82-3419
lars.hegenbart at kit.edu
http://www.hs-kes.de



More information about the Insight-users mailing list