[Insight-users] hi
Luis Ibanez
luis.ibanez at kitware.com
Sat Apr 28 14:10:29 EDT 2012
Hi Santhosh,
Thanks for letting us know that you have found the source of the problem.
I'm surprised about the difference of behavior between Release and Debug
modes. However, not being an xcode developer, I may not be able to help
on that front.
We will be very interested in hearing about your progress on using ITK
in the iPad (and in general iOS devices). This could be a great topic for
an Insight Journal article:
http://www.insight-journal.org
Thanks
Luis
----------------------------------------------
On Sat, Apr 28, 2012 at 2:05 PM, santhosh jayapal <nuteron at gmail.com> wrote:
> Hi Luis,
> I figured out the problem yestarday. The code was proper, the issue was that
> i was running the code in the 'release' mode in xcode.
> Release mode is generally used for running the application on a device. Am
> just working on simulator for now(debug mode). But need to see what i should
> when i have to run the app in the release mode(which is the actual required
> mode). Need to check the core differences between release and debug mode.
> Other wise the filter is working for image rotation perfectly, itk frame
> work is very helpful. Next need to work on image scaling.
> Thanks
> Santosh..
>
>
> On Sat, Apr 28, 2012 at 10:55 AM, Luis Ibanez <luis.ibanez at kitware.com>
> wrote:
>>
>> Hi Santhosh,
>>
>> Here are some ideas that may help.
>>
>> 0) In the resample filter use the SetReferenceImage option
>> instead of using SetSize, SetOrigin, SetSpacing... etc.
>> Using the Reference image is a less error-prone method.
>>
>> 1) Test the code with a null transformation (zero rotation,
>> zero translation).
>>
>> 2) Take advantage of the CenteredTransformInitializer class,
>> (with the "Geometry" option) to create a transform that by
>> default maps the input image to the output image. In that
>> way you don't have to manually compute the centering
>> transformation.
>>
>>
>> Please let us know how it goes.
>>
>>
>> Thanks
>>
>>
>> Luis
>>
>>
>> -------------------------------------------
>> On Thu, Apr 19, 2012 at 8:37 AM, santhosh jayapal <nuteron at gmail.com>
>> wrote:
>> > Hi Luis,
>> > How are you doing?
>> > Am working on displaying dicom files on the ipad using itk. Had mailed
>> > you
>> > few months back about some issues i was facing with dicom and itk and
>> > your
>> > suggestions were greatly helpfull. The project was on hold for some
>> > reason
>> > and got resumed few days back.
>> > Am facing with a problem from 2 days, ie i want to rotate a dicom image
>> > using the 'itk: resamping filters' for rotation. I followed the example
>> > file
>> > and implemented it as you had given. But what is happening is the
>> > filters
>> > output is always coming null to the writers input.
>> > Will share the code with you, please see if you can find any thing wrong
>> > happening in this code.
>> >
>> > const unsigned int Dimension = 2;
>> > typedef unsigned short GrayScalePixelType;
>> > typedef itk::Image <GrayScalePixelType,2> GrayscaleImageType;
>> > //Image -
>> > Contain the pixels and no. of dimensions.
>> >
>> > typedef itk::ImageFileWriter <GrayscaleImageType> writerType;
>> > writerType::Pointer writer = writerType::New();
>> >
>> > writer->SetFileName([@"/Users/santoshjayapal/skullTempNewFileter.dcm"
>> > UTF8String]);
>> >
>> > typedef itk::ImageFileReader <GrayscaleImageType>
>> > GrayScaleReaderType;
>> > //ImageFileReader -This source object is a general filter to read data
>> > from
>> > GrayScaleReaderType::Pointer GrayScaleReader =
>> > GrayScaleReaderType::New(); //pointer - LightObject is the highest level
>> > base class for most itk objects.
>> >
>> > //*/
>> > //adding gdcm object for the reader:
>> > typedef itk::GDCMImageIO ImageIOType; //GDCMImageIO.h - brief
>> > ImageIO
>> > class for reading and writing DICOM V3.0
>> > ImageIOType::Pointer dicomIO = ImageIOType::New();
>> > GrayScaleReader->SetImageIO( dicomIO );
>> > GrayScaleReader->SetFileName([dicomFilePath UTF8String]);
>> >
>> >
>> > typedef itk::ResampleImageFilter<
>> > GrayscaleImageType, GrayscaleImageType > FilterType;
>> >
>> > FilterType::Pointer filter = FilterType::New();
>> >
>> >
>> > typedef itk::AffineTransform< double, Dimension > TransformType;
>> > TransformType::Pointer transform = TransformType::New();
>> > // Software Guide : EndCodeSnippet
>> >
>> >
>> > typedef itk::LinearInterpolateImageFunction<
>> > GrayscaleImageType, double > InterpolatorType;
>> > InterpolatorType::Pointer interpolator = InterpolatorType::New();
>> >
>> > filter->SetInterpolator( interpolator );
>> >
>> > filter->SetDefaultPixelValue( 100 );
>> >
>> > GrayScaleReader->Update();
>> >
>> > const GrayscaleImageType * inputImage =
>> > GrayScaleReader->GetOutput();
>> >
>> > const GrayscaleImageType::SpacingType & spacing =
>> > inputImage->GetSpacing();
>> > const GrayscaleImageType::PointType & origin =
>> > inputImage->GetOrigin();
>> > GrayscaleImageType::SizeType size =
>> > inputImage->GetLargestPossibleRegion().GetSize();
>> >
>> > filter->SetOutputOrigin( origin );
>> > filter->SetOutputSpacing( spacing );
>> > filter->SetOutputDirection( inputImage->GetDirection() );
>> > filter->SetSize( size );
>> >
>> > filter->SetInput( GrayScaleReader->GetOutput() );
>> > writer->SetInput( filter->GetOutput() );
>> >
>> >
>> > TransformType::OutputVectorType translation1;
>> >
>> > const double imageCenterX = origin[0] + spacing[0] * size[0] / 2.0;
>> > const double imageCenterY = origin[1] + spacing[1] * size[1] / 2.0;
>> >
>> > translation1[0] = -imageCenterX;
>> > translation1[1] = -imageCenterY;
>> >
>> > transform->Translate( translation1 );
>> >
>> >
>> > const double degreesToRadians = vcl_atan(1.0) / 45.0;
>> > const double angle = 45.00 * degreesToRadians;
>> > transform->Rotate2D( -angle, false );
>> >
>> > TransformType::OutputVectorType translation2;
>> > translation2[0] = imageCenterX;
>> > translation2[1] = imageCenterY;
>> > transform->Translate( translation2, false );
>> > filter->SetTransform( transform );
>> > try
>> > {
>> > writer->Update();
>> > }
>> > catch( itk::ExceptionObject & excep )
>> > {
>> > std::cerr << "Exception caught !" << std::endl;
>> > std::cerr << excep << std::endl;
>> > }
>> >
>> > Am not getting any errors though, but wen i update the write outside the
>> > try
>> > the code crashes. Please let me know what is wrong , i was thinking i
>> > need
>> > to compile the itk libraries again using cmake since its been a long
>> > time
>> > since i worked on the project and some file might have been deleted,
>> > should
>> > i do that pls let me know.
>> >
>> > Thanks ,
>> > Santhosh
>
>
More information about the Insight-users
mailing list