<br>My image ix 1388x560x53. It appears that a 90 deg rotation around the x axis produces an image that is still 53 slices thick, rather than 1388 slices. Any suggestions on how to simply rotate the image? I've tried changing the output size of the filter, but that produces a blank image.<br>
<br><br><br><div class="gmail_quote">On Mon, Dec 6, 2010 at 12:06 PM, Kevin Neff <span dir="ltr"><<a href="mailto:kevin.l.neff@gmail.com">kevin.l.neff@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Right. After fixing this foolish error, it seems to be working. <br><br>Still, the final dimensions are identical to the original dimensions. If I rotate the image 90 deg around the x axis, the width will not change but the height and depth should change. Is there a way to expand the "canvas" (putting it in GIMP/Photoshop terms)?<br>
<br>KLN<br><br><br><br><div class="gmail_quote"><div class="im">On Sat, Dec 4, 2010 at 6:45 PM, Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
Hi Kevin,<br>
<br>
Seth is right,<br>
the signature of the Rotate3D method is:<br>
<br>
void Rotate3D(const OutputVectorType & axis, TScalarType angle,<br>
bool pre = 0);<br>
<br></div> ......</blockquote><div><div></div><div class="h5"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Luis<br>
<br>
<br>
-------------------------------------------------------------<br>
<div><div></div><div>On Fri, Dec 3, 2010 at 12:07 PM, Kevin Neff <<a href="mailto:kevin.l.neff@gmail.com" target="_blank">kevin.l.neff@gmail.com</a>> wrote:<br>
><br>
> Of the potential problems mentioned, the most obvious is getting the data<br>
> oriented roughly, so I'm trying to do that first. I'm using<br>
> ResampleImageFilter4.cxx, modified for 3D rotation. Input and output is<br>
> mhd, unsigned shorts.<br>
><br>
> When I rotate the volume by any amount, there is no visible difference. I<br>
> tried 0, 1, 10, 45, 89, and 90 deg. What am I doing wrong?<br>
><br>
> When a volume is rotated, the dimensions of the volume in the output mhd<br>
> file should account for it, right? So rotating 45 deg should increase one<br>
> of the dimensions.<br>
><br>
><br>
><br>
> #include "itkImage.h"<br>
> #include "itkImageFileReader.h"<br>
> #include "itkImageFileWriter.h"<br>
> #include "itkResampleImageFilter.h"<br>
> #include "itkLinearInterpolateImageFunction.h"<br>
><br>
><br>
> #include "itkAffineTransform.h"<br>
><br>
><br>
> int main( int argc, char * argv[] )<br>
> {<br>
> if( argc < 4 )<br>
> {<br>
> std::cerr << "Usage: " << std::endl;<br>
> std::cerr << argv[0] << " inputImageFile outputImageFile degrees" <<<br>
> std::endl;<br>
> return EXIT_FAILURE;<br>
> }<br>
><br>
> const unsigned int Dimension = 3;<br>
> typedef unsigned short InputPixelType;<br>
> typedef unsigned short OutputPixelType;<br>
><br>
> typedef itk::Image< InputPixelType, Dimension > InputImageType;<br>
> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br>
><br>
> typedef itk::ImageFileReader< InputImageType > ReaderType;<br>
> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br>
><br>
> ReaderType::Pointer reader = ReaderType::New();<br>
> WriterType::Pointer writer = WriterType::New();<br>
><br>
> reader->SetFileName( argv[1] );<br>
> writer->SetFileName( argv[2] );<br>
><br>
> const double angleInDegrees = atof( argv[3] );<br>
><br>
> typedef itk::ResampleImageFilter<<br>
> InputImageType, OutputImageType > FilterType;<br>
><br>
> FilterType::Pointer filter = FilterType::New();<br>
><br>
><br>
><br>
> typedef itk::AffineTransform< double, Dimension > TransformType;<br>
> TransformType::Pointer transform = TransformType::New();<br>
><br>
><br>
> typedef itk::LinearInterpolateImageFunction<<br>
> InputImageType, double > InterpolatorType;<br>
> InterpolatorType::Pointer interpolator = InterpolatorType::New();<br>
><br>
> filter->SetInterpolator( interpolator );<br>
><br>
> filter->SetDefaultPixelValue( 100 );<br>
><br>
><br>
> reader->Update();<br>
><br>
> const InputImageType * inputImage = reader->GetOutput();<br>
><br>
> const InputImageType::SpacingType & spacing = inputImage->GetSpacing();<br>
> const InputImageType::PointType & origin = inputImage->GetOrigin();<br>
> InputImageType::SizeType size =<br>
> inputImage->GetLargestPossibleRegion().GetSize();<br>
><br>
> filter->SetOutputOrigin( origin );<br>
> filter->SetOutputSpacing( spacing );<br>
> filter->SetOutputDirection( inputImage->GetDirection() );<br>
> filter->SetSize( size );<br>
><br>
><br>
> filter->SetInput( reader->GetOutput() );<br>
> writer->SetInput( filter->GetOutput() );<br>
><br>
><br>
> TransformType::OutputVectorType translation1;<br>
><br>
> const double imageCenterX = origin[0] + spacing[0] * size[0] / 2.0;<br>
> const double imageCenterY = origin[1] + spacing[1] * size[1] / 2.0;<br>
> const double imageCenterZ = origin[2] + spacing[2] * size[2] / 2.0;<br>
><br>
> translation1[0] = -imageCenterX;<br>
> translation1[1] = -imageCenterY;<br>
> translation1[2] = -imageCenterZ;<br>
> transform->Translate( translation1 );<br>
><br>
> std::cout << "imageCenterX = " << imageCenterX << std::endl;<br>
> std::cout << "imageCenterY = " << imageCenterY << std::endl;<br>
> std::cout << "imageCenterZ = " << imageCenterZ << std::endl;<br>
><br>
><br>
> const double degreesToRadians = vcl_atan(1.0) / 45.0;<br>
> const double angle = angleInDegrees * degreesToRadians;<br>
> transform->Rotate3D( -angle, false );<br>
><br>
><br>
> TransformType::OutputVectorType translation2;<br>
> translation2[0] = imageCenterX;<br>
> translation2[1] = imageCenterY;<br>
> translation2[2] = imageCenterZ;<br>
> transform->Translate( translation2, false );<br>
> filter->SetTransform( transform );<br>
><br>
> try<br>
> {<br>
> writer->Update();<br>
> }<br>
> catch( itk::ExceptionObject & excep )<br>
> {<br>
> std::cerr << "Exception caught !" << std::endl;<br>
> std::cerr << excep << std::endl;<br>
> }<br>
><br>
> return EXIT_SUCCESS;<br>
> }<br>
><br>
><br>
><br>
><br>
><br>
><br>
> On Tue, Nov 30, 2010 at 9:29 PM, Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>><br>
> wrote:<br>
>><br>
>> Hi Kevin<br>
>><br>
>> On Tue, Nov 30, 2010 at 1:23 PM, Kevin Neff <<a href="mailto:kevin.l.neff@gmail.com" target="_blank">kevin.l.neff@gmail.com</a>><br>
>> wrote:<br>
>> ><br>
>> > Thanks, Dan. I used the example ImageRegistration8.cxx with my data.<br>
>> ><br>
>> > First, it's terribly slow. Is there anything I can do to speed it up?<br>
>><br>
>><br>
>> 1) How long it took ?<br>
>><br>
>> 2) How many cores do you have ?<br>
>><br>
>> 3) What version of ITK are you using ?<br>
>><br>
>> 4) Make sure that you compile it for Release mode.<br>
>> (that easily makes a difference of 10x with respect to Debug mode).<br>
>><br>
>><br>
>> > my limited experience, applying a threshold first and skipping rotation<br>
>> > of<br>
>> > voxels below the threshold helped. Or could I pre-compute isotropic<br>
>> > voxels<br>
>> > and skip the interpolation that follows image rotation and just<br>
>> > interpolate<br>
>> > the final solution? Any suggestion is welcome!<br>
>> ><br>
>><br>
>> You could also use a Mask,<br>
>> See example:<br>
>><br>
>> ITK/Examples/Registration/ImageRegistration12.cxx<br>
>><br>
>><br>
>> > Second, after 200 iterations, the output does not appear correct. I<br>
>> > ran it<br>
>> > with data that had the dimensions 13888x560x48 and 1388x560x53 but the<br>
>> > output had the dimensions 13888x560x48. The volumes were of the shell<br>
>> > of a<br>
>> > large object, rotated 90 deg, so I'm sure the dimension of the output<br>
>> > should<br>
>> > have been much larger---something like 1388x1000x100.<br>
>><br>
>> a) 90 degrees is beyond the capture radio of any registration method.<br>
>> You must initialize the Transform to account for most of that rotation.<br>
>> In practice you shouldn't expect the optimization process to correct<br>
>> for more than 20 to 30 degrees of rotation.<br>
>><br>
>> b) Is that rotation along the long axis of your image ? or perpendicular<br>
>> to it ?<br>
>> A screen shot of your image will be very helpful...<br>
>><br>
>> c) You should carefully control the parameter scales to make sure that<br>
>> you account for the proportion of radians units (used for rotation) to<br>
>> millimeters used for translation.<br>
>><br>
>> d) What is the pixel spacing of your images ?<br>
>><br>
>><br>
>> ><br>
>> > KLN<br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > On Sun, Nov 21, 2010 at 7:55 AM, Dan Mueller <<a href="mailto:dan.muel@gmail.com" target="_blank">dan.muel@gmail.com</a>> wrote:<br>
>> >><br>
>> >> Hi Kevin,<br>
>> >><br>
>> >> I highly recommending the entire ITK Software Guide:<br>
>> >> <a href="http://www.itk.org/ItkSoftwareGuide.pdf" target="_blank">http://www.itk.org/ItkSoftwareGuide.pdf</a><br>
>> >><br>
>> >> For your specific question, see section 8.8.<br>
>> >><br>
>> >> In short:<br>
>> >><br>
>> >> IdentityTransform: identity<br>
>> >> TranslationTransform: n-D translation<br>
>> >> ScaleTransform: n-D scaling<br>
>> >> CenteredRigid2DTransform: 2-D rotation + translation<br>
>> >> Similarity2DTransform: 2-D scaling + rotation + translation<br>
>> >> VersorTransform: 3-D rotation<br>
>> >> VersorRigid3DTransform: 3-D rotation + translation<br>
>> >> Similarity3DTransform: 3-D scaling + rotation + translation<br>
>> >> AffineTransform: n-D scaling + rotation + translation + shear<br>
>> >><br>
>> >> HTH<br>
>> >><br>
>> >> Cheers, Dan<br>
>> >><br>
>> >> On 21 November 2010 13:49, Kevin Neff <<a href="mailto:kevin.l.neff@gmail.com" target="_blank">kevin.l.neff@gmail.com</a>> wrote:<br>
>> >> ><br>
>> >> > I need to register images using rotation and translation. Is that<br>
>> >> > possible<br>
>> >> > with theITK classes, or do I have to write my own?<br>
>> >> ><br>
>> >> > I'm basing this question on a translation-only example and the list<br>
>> >> > of<br>
>> >> > classes derived from AffineTransform<br>
>> >> ><br>
>> >> > <a href="http://www.itk.org/Wiki/ITK_Image_Registration" target="_blank">http://www.itk.org/Wiki/ITK_Image_Registration</a><br>
>> ><br>
>> ><br>
>> > _____________________________________<br>
>> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>> ><br>
>> > Visit other Kitware open-source projects at<br>
>> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>> ><br>
>> > Kitware offers ITK Training Courses, for more information visit:<br>
>> > <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
>> ><br>
>> > Please keep messages on-topic and check the ITK FAQ at:<br>
>> > <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>> ><br>
>> > Follow this link to subscribe/unsubscribe:<br>
>> > <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
>> ><br>
>> ><br>
><br>
><br>
> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br>