[Insight-users] problem in drawing a line in an image

Raviteja, Allaparthi Allaparthi.Raviteja at philips.com
Mon Oct 8 08:21:03 EDT 2012


Hi,



I want to draw a line in to an image .

>

>

>

> #include <iostream>

> #include "itkImageFileWriter.h"

> #include "itkLineConstIterator.h"

>

>   #include "itkImage.h"

>

>

>

> int main(int argc, char *argv[])

>

>

>

> {

>

>      if( argc < 2 )

>

>     {

>

>     std::cerr << "Usage: " << std::endl;

>

>     std::cerr << argv[0] << "  outputImageFile " << std::endl;

>

>     return EXIT_FAILURE;

>

>        }

>

>        typedef itk::Image<unsigned char, 2>  ImageType;

>

>   ImageType::Pointer image = ImageType::New();

>

>

>

>   typedef itk::Image<unsigned char, 2> ImageType;

>   ImageType::Pointer image = ImageType::New();

>   typedef itk::ImageFileWriter<ImageType> FileWriterType;

>

>

>   typedef itk::LineConstIterator< ImageType > LineIteratorType;

>   ImageType::IndexType point0;

>   point0[0] = 46;

>   point0[1] = 232;

>

>   ImageType::IndexType point1;

>   point1[0] = 433;

>   point1[1] = 477;

>

>   LineIteratorType it( image, point0, point1);

>   it.GoToBegin();

>   while (!it.IsAtEnd())

>     {

>     std::cout << (float)it.Get() << std::endl;

>     ++it;

>     }

>

>

>

>   FileWriterType::Pointer writer= FileWriterType::New();

>

>     writer->SetFileName(argv[1]);

>

>        writer->SetInput(image);

>

>     writer->Update();

>

>       cout<<"--->line iterator passed "<<endl;

>

>

>

>   return EXIT_SUCCESS;

> }

>



I am in a confusion of setting the input here "writer->SetInput(image);" .  Could someone please help me out ?

I am using InsightToolkit-4.1.0 with Visual Studio 2010 on Windows 7.



>

>

>

>

>

>

> Regards,

>

> Ravi Teja.


________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121008/5436a9e3/attachment.htm>


More information about the Insight-users mailing list