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

Chr. Rossmanith cr at neuro.ma.uni-heidelberg.de
Wed Oct 10 06:49:58 EDT 2012


Hi,

you have to allocate memory for your image data I guess. In my 
modification of your example I'm reading an existing image so I don't 
have to allocate memory. And I've changed itkLineConstIterator to the 
non-const iterator in order to modify the image data along the line.

See also http://www.vtk.org/Wiki/ITK/Examples/Iterators/LineIterator  
there you'll find an example for creating an image from scratch.

Christina Roßmanith
--
Dept. of Neurology
University Medical Center Mannheim


Am 08.10.2012 14:21, schrieb Raviteja, Allaparthi:
>
> 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.
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121010/9ff8c4f5/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkDraw.cxx
Type: text/x-c++src
Size: 1285 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121010/9ff8c4f5/attachment.cxx>


More information about the Insight-users mailing list