<div>Dear All,</div> <div>I am a new user of ITK. I am trying to read and and write image files using the ITK and Cmakesetup (for configuring).I successfully run the helloWorld code(to test the itk is running properly). </div> <div>I have copied the <FONT face=Courier size=2></div> <div align=left>Examples/IO/ImageReadWrite.cxx</FONT><FONT face="Times New Roman" size=2>. </FONT></div> <div align=left><FONT face="Times New Roman" size=2><FONT size=4>file to another directory "ImageReadWrite". I have created the following 'CMakeLists.txt' file in the same directory.</FONT></div></FONT> <div><BR>PROJECT(ImageReadWrite)<BR># Find ITK.<BR>FIND_PACKAGE(ITK REQUIRED)<BR>IF(ITK_FOUND)<BR> INCLUDE(${ITK_USE_FILE})<BR>ENDIF(ITK_FOUND)<BR>ADD_EXECUTABLE(ImageReadWrite ImageReadWrite.cxx )<BR>TARGET_LINK_LIBRARIES(ImageReadWrite ITKIO)</div> <div>......</div> <div>I have modified the ImageReadWrite.cxx code in the following place</div> <div> </div>
<div>reader->SetFileName( "BrainProtonDensitySlice.png" );<BR> writer->SetFileName( "BrainProtonDensitySlice_w.png" );</div> <div> </div> <div>I have also copied the image file "BrainProtonDensitySlice.png" to the same directory.</div> <div> </div> <div>Now using the CMakeSetUp, I configured it (source and binary build directing are same). I got the ImageReadWrite.dsw workspace. I opened this in Visual Studio 6 and built all files successfully. I run the ImageReadWrite.exe file. It gave following output</div> <div>"</div> <div>usage:</div> <div>C:\...\ImageReadWrite\Debug\ImageReadWrite.exe inputImageFile <A>outputImageFile</A>"</div> <div> </div> <div>The program is not reading and writing the image. Please suggest what went wrong and help me correcting the problem</div> <div>Thanks</div> <div>KPatra</div> <div>Singapore</div>
<div> </div> <div><B><I></I></B> </div> <div><B><I></I></B> </div> <div><B><I></I></B> </div> <div><B><I>insight-users-request@itk.org</I></B> wrote:</div> <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Send Insight-users mailing list submissions to<BR>insight-users@itk.org<BR><BR>To subscribe or unsubscribe via the World Wide Web, visit<BR>http://www.itk.org/mailman/listinfo/insight-users<BR>or, via email, send a message with subject or body 'help' to<BR>insight-users-request@itk.org<BR><BR>You can reach the person managing the list at<BR>insight-users-owner@itk.org<BR><BR>When replying, please edit your Subject line so it is more specific<BR>than "Re: Contents of Insight-users digest..."<BR><BR><BR>Today's Topics:<BR><BR>1. locally rigid transformations
(William Am)<BR>2. Re: How to register 2D RGB images (Jinzhong Yang)<BR><BR><BR>----------------------------------------------------------------------<BR><BR>Message: 1<BR>Date: Mon, 14 Jan 2008 08:39:37 -0800 (PST)<BR>From: William Am <MARIAN88@LIVE.CA><BR>Subject: [Insight-users] locally rigid transformations<BR>To: insight-users@itk.org<BR>Message-ID: <14805008.post@talk.nabble.com><BR>Content-Type: text/plain; charset=us-ascii<BR><BR><BR>Hi all,<BR><BR>How might one begin implementing propagation of locally rigid<BR>transformations as described in the work below?<BR><BR>http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1616288<BR><BR>Thanks,<BR>Will<BR>-- <BR>View this message in context: http://www.nabble.com/locally-rigid-transformations-tp14805008p14805008.html<BR>Sent from the ITK - Users mailing list archive at Nabble.com.<BR><BR><BR><BR>------------------------------<BR><BR>Message: 2<BR>Date: Mon, 14 Jan 2008 11:53:44 -0500<BR>From: "Jinzhong Yang"
<JINZHONG.YANG@IEEE.ORG><BR>Subject: Re: [Insight-users] How to register 2D RGB images<BR>To: "chunfang wang" <WCHUNFANG@GMAIL.COM><BR>Cc: "insight-users@itk.org" <INSIGHT-USERS@ITK.ORG><BR>Message-ID:<BR><9190305b0801140853w26f0491tbae43b21fe2051c3@mail.gmail.com><BR>Content-Type: text/plain; charset="iso-8859-1"<BR><BR>I guess the problem is the metric you used to compare two RGB pixels. You<BR>are not able to use class itkMeanSquaresImageToImageMetric to compare two<BR>pixels in vector format. There is an example to register two RGB images:<BR><BR><BR>http://www.seas.upenn.edu/~jtduda/itkvector.html<BR><BR><BR>Good luck,<BR>Jinzhong<BR><BR><BR>On Jan 14, 2008 9:26 AM, chunfang wang <WCHUNFANG@GMAIL.COM>wrote:<BR><BR>> Hello Luis,<BR>><BR>> I am a new user of itk, but no one in my lab have used it. So, when some<BR>> problems comes, I am so sad.<BR>> Looking forward of your help~~~<BR>><BR>> I have some problems in the registration of RGB
images.<BR>> Now I explain my problems in detail:<BR>><BR>> my work is to register two RGB images using the CenteredRigid2DTransform<BR>> I have set the VectorResampleFilter and VectorInterpolater<BR>> but still the complier error is<BR>><BR>> d:\program files\itk\insighttoolkit-3.4.0\code\common\itkCovariantVector.h(75)<BR>> : error C2039: 'RealType' : is not a member of 'itk::NumericTraits<T>'<BR>> 1> with<BR>> 1> [<BR>> 1> T=itk::RGBPixel<DOUBLE><BR>> 1> ]<BR>> 1> D:\program files\itk\InsightToolkit-<BR>> 3.4.0\Code\Common\itkPixelTraits.h(39) : see reference to class template<BR>> instantiation 'itk::CovariantVector<T,NVECTORDIMENSION>' being compiled<BR>> 1> with<BR>> 1> [<BR>> 1> T=itk::RGBPixel<DOUBLE>,<BR>> 1> NVectorDimension=2<BR>> 1> ]<BR>><BR>> I don't know how to settle this problem, please give me some help!<BR>> thanks very much<BR>><BR>> my code is just
refied the examples in itk<BR>><BR>> #include "itkImageRegistrationMethod.h"<BR>> #include "itkMeanSquaresImageToImageMetric.h"<BR>> #include "itkVectorLinearInterpolateImageFunction.h"<BR>> #include "itkRegularStepGradientDescentOptimizer.h "<BR>> #include "itkImage.h"<BR>> #include "itkRGBPixel.h"<BR>> #include "itkCenteredRigid2DTransform.h"<BR>><BR>> #include "itkImageFileReader.h"<BR>> #include "itkImageFileWriter.h"<BR>><BR>> #include "itkVectorResampleImageFilter.h"<BR>> #include "itkSubtractImageFilter.h"<BR>> #include "itkRescaleIntensityImageFilter.h"<BR>><BR>> int main( int argc, char *argv[] )<BR>> {<BR>> if( argc < 4 )<BR>> {<BR>> std::cerr << "Missing Parameters " << std::endl;<BR>> std::cerr << "Usage: " << argv[0];<BR>> std::cerr << " fixedImageFile movingImageFile ";<BR>> std::cerr << " outputImagefile [differenceAfterRegistration] ";<BR>>
std::cerr << " [differenceBeforeRegistration] ";<BR>> std::cerr << " [initialStepLength] "<< std::endl;<BR>> return EXIT_FAILURE;<BR>> }<BR>><BR>> const unsigned int Dimension = 2;<BR>> typedef itk::RGBPixel< unsigned char > PixelType;<BR>><BR>> typedef itk::Image< PixelType, Dimension > FixedImageType;<BR>> typedef itk::Image< PixelType, Dimension > MovingImageType;<BR>> typedef itk::CenteredRigid2DTransform< double > TransformType;<BR>><BR>> typedef itk::RegularStepGradientDescentOptimizer OptimizerType;<BR>> typedef itk::MeanSquaresImageToImageMetric<<BR>> FixedImageType,<BR>> MovingImageType > MetricType;<BR>> typedef itk:: VectorLinearInterpolateImageFunction<<BR>> MovingImageType,<BR>> double > InterpolatorType;<BR>> typedef itk::ImageRegistrationMethod<<BR>> FixedImageType,<BR>> MovingImageType > RegistrationType;<BR>><BR>>
MetricType::Pointer metric = MetricType::New();<BR>> OptimizerType::Pointer optimizer = OptimizerType::New();<BR>> InterpolatorType::Pointer interpolator = InterpolatorType::New();<BR>> RegistrationType::Pointer registration = RegistrationType::New();<BR>><BR>> registration->SetMetric( metric );<BR>> registration->SetOptimizer( optimizer );<BR>> registration->SetInterpolator( interpolator );<BR>><BR>><BR>> TransformType::Pointer transform = TransformType::New();<BR>> registration->SetTransform( transform );<BR>><BR>><BR>> typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;<BR>> typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;<BR>><BR>> FixedImageReaderType::Pointer fixedImageReader =<BR>> FixedImageReaderType::New();<BR>> MovingImageReaderType::Pointer movingImageReader =<BR>> MovingImageReaderType::New();<BR>><BR>>
fixedImageReader->SetFileName( argv[1] );<BR>> movingImageReader->SetFileName( argv[2] );<BR>><BR>><BR>> registration->SetFixedImage( fixedImageReader->GetOutput() );<BR>> registration->SetMovingImage( movingImageReader->GetOutput() );<BR>> fixedImageReader->Update();<BR>><BR>> registration->SetFixedImageRegion(<BR>> fixedImageReader->GetOutput()->GetBufferedRegion() );<BR>> fixedImageReader->Update();<BR>> movingImageReader->Update();<BR>><BR>> typedef FixedImageType::SpacingType SpacingType;<BR>> typedef FixedImageType::PointType OriginType;<BR>> typedef FixedImageType::RegionType RegionType;<BR>> typedef FixedImageType::SizeType SizeType;<BR>> FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();<BR>><BR>> const SpacingType fixedSpacing = fixedImage->GetSpacing();<BR>> const OriginType fixedOrigin = fixedImage->GetOrigin();<BR>> const RegionType
fixedRegion = fixedImage->GetLargestPossibleRegion();<BR>> const SizeType fixedSize = fixedRegion.GetSize();<BR>><BR>> TransformType::InputPointType centerFixed;<BR>><BR>> centerFixed[0] = fixedOrigin[0] + fixedSpacing[0] * fixedSize[0] / 2.0;<BR>> centerFixed[1] = fixedOrigin[1] + fixedSpacing[1] * fixedSize[1] / 2.0;<BR>><BR>> MovingImageType::Pointer movingImage = movingImageReader->GetOutput();<BR>><BR>> const SpacingType movingSpacing = movingImage->GetSpacing();<BR>> const OriginType movingOrigin = movingImage->GetOrigin();<BR>> const RegionType movingRegion =<BR>> movingImage->GetLargestPossibleRegion();<BR>> const SizeType movingSize = movingRegion.GetSize();<BR>><BR>> TransformType::InputPointType centerMoving;<BR>><BR>> centerMoving[0] = movingOrigin[0] + movingSpacing[0] * movingSize[0] /<BR>> 2.0;<BR>> centerMoving[1] = movingOrigin[1] + movingSpacing[1] * movingSize[1] /<BR>>
2.0;<BR>><BR>> transform->SetCenter( centerFixed );<BR>> transform->SetTranslation( centerMoving - centerFixed );<BR>> transform->SetAngle( 0.0 );<BR>><BR>><BR>> registration->SetInitialTransformParameters( transform->GetParameters()<BR>> );<BR>><BR>> // Software Guide : BeginCodeSnippet<BR>> typedef OptimizerType::ScalesType OptimizerScalesType;<BR>> OptimizerScalesType optimizerScales( transform->GetNumberOfParameters()<BR>> );<BR>> const double translationScale = 1.0 / 1000.0;<BR>><BR>> optimizerScales[0] = 1.0;<BR>> optimizerScales[1] = translationScale;<BR>> optimizerScales[2] = translationScale;<BR>> optimizerScales[3] = translationScale;<BR>> optimizerScales[4] = translationScale;<BR>><BR>> optimizer->SetScales( optimizerScales );<BR>><BR>> double initialStepLength = 0.1;<BR>> // Software Guide : EndCodeSnippet<BR>><BR>> if( argc > 6 )<BR>> {<BR>>
initialStepLength = atof( argv[6] );<BR>> }<BR>><BR>> // Software Guide : BeginCodeSnippet<BR>> optimizer->SetRelaxationFactor( 0.6 );<BR>> optimizer->SetMaximumStepLength( initialStepLength );<BR>> optimizer->SetMinimumStepLength( 0.001 );<BR>> optimizer->SetNumberOfIterations( 200 );<BR>> // Software Guide : EndCodeSnippet<BR>><BR>><BR>> // Create the Command observer and register it with the optimizer.<BR>> //<BR>> CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();<BR>> optimizer->AddObserver( itk::IterationEvent(), observer );<BR>><BR>> try<BR>> {<BR>> registration->StartRegistration();<BR>> }<BR>> catch( itk::ExceptionObject & err )<BR>> {<BR>> std::cerr << "ExceptionObject caught !" << std::endl;<BR>> std::cerr << err << std::endl;<BR>> return EXIT_FAILURE;<BR>> }<BR>><BR>> OptimizerType::ParametersType finalParameters
=<BR>> registration->GetLastTransformParameters();<BR>><BR>> const double finalAngle = finalParameters[0];<BR>> const double finalRotationCenterX = finalParameters[1];<BR>> const double finalRotationCenterY = finalParameters[2];<BR>> const double finalTranslationX = finalParameters[3];<BR>> const double finalTranslationY = finalParameters[4];<BR>><BR>> const unsigned int numberOfIterations = optimizer->GetCurrentIteration();<BR>><BR>> const double bestValue = optimizer->GetValue();<BR>><BR>> typedef itk::VectorResampleImageFilter<<BR>> MovingImageType,<BR>> FixedImageType > ResampleFilterType;<BR>><BR>> TransformType::Pointer finalTransform = TransformType::New();<BR>><BR>> finalTransform->SetParameters( finalParameters );<BR>><BR>> ResampleFilterType::Pointer resample = ResampleFilterType::New();<BR>><BR>> resample->SetTransform( finalTransform );<BR>> resample->SetInput(
movingImageReader->GetOutput() );<BR>><BR>> resample->SetSize( fixedImage->GetLargestPossibleRegion().GetSize() );<BR>> resample->SetOutputOrigin( fixedImage->GetOrigin() );<BR>> resample->SetOutputSpacing( fixedImage->GetSpacing() );<BR>> resample->SetDefaultPixelValue( 100 );<BR>><BR>> typedef itk::ImageFileWriter< FixedImageType > WriterFixedType;<BR>><BR>> WriterFixedType::Pointer writer = WriterFixedType::New();<BR>><BR>> writer->SetFileName( argv[3] );<BR>><BR>> writer->SetInput( resample->GetOutput() );<BR>><BR>> try<BR>> {<BR>> writer->Update();<BR>> }<BR>> catch( itk::ExceptionObject & excp )<BR>> {<BR>> std::cerr << "ExceptionObject while writing the resampled image !" <<<BR>> std::endl;<BR>> std::cerr << excp << std::endl;<BR>> return EXIT_FAILURE;<BR>> }<BR>> }<BR>><BR>>
_______________________________________________<BR>> Insight-users mailing list<BR>> Insight-users@itk.org<BR>> http://www.itk.org/mailman/listinfo/insight-users<BR>><BR>><BR>-------------- next part --------------<BR>An HTML attachment was scrubbed...<BR>URL: http://public.kitware.com/pipermail/insight-users/attachments/20080114/e938b65f/attachment-0001.html<BR><BR>------------------------------<BR><BR>_______________________________________________<BR>Insight-users mailing list<BR>Insight-users@itk.org<BR>http://www.itk.org/mailman/listinfo/insight-users<BR><BR><BR>End of Insight-users Digest, Vol 45, Issue 14<BR>*********************************************<BR></BLOCKQUOTE><BR><p> 
<!--5--><hr size=1></hr> Now you can chat without downloading messenger. <a href="http://in.rd.yahoo.com/tagline_webmessenger_5/*http://in.messenger.yahoo.com/webmessengerpromo.php">Click here</a> to know how.