<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<link href="chrome://translator/skin/floatingPanel.css"
type="text/css" rel="stylesheet">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi,<br>
<br>
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.<br>
<br>
See also
<a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/ITK/Examples/Iterators/LineIterator">http://www.vtk.org/Wiki/ITK/Examples/Iterators/LineIterator</a> there
you'll find an example for creating an image from scratch.<br>
<br>
Christina Roßmanith<br>
--<br>
<span
style="font-size:10pt;font-family:"Arial","sans-serif""
lang="EN-GB">Dept. of Neurology</span> <br>
<span
style="font-size:10pt;font-family:"Arial","sans-serif""
lang="EN-GB">University Medical Center Mannheim<br>
<br>
</span><br>
Am 08.10.2012 14:21, schrieb Raviteja, Allaparthi:<br>
</div>
<blockquote
cite="mid:4E2CCF5105F8F04B8F4C8C27EF66D089014E27F5@011-DB3MPN2-131.MGDPHG.emi.philips.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<style>
<!--
@font-face
        {font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif"}
span.EmailStyle17
        {font-family:"Calibri","sans-serif";
        color:windowtext}
span.PlainTextChar
        {font-family:"Calibri","sans-serif"}
.MsoChpDefault
        {font-family:"Calibri","sans-serif"}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.WordSection1
        {}
-->
</style>
<div class="WordSection1">
<p class="MsoPlainText">Hi,</p>
<p class="MsoPlainText"> </p>
<p class="MsoPlainText">I want to draw a line in to an image .</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> #include <iostream></p>
<p class="MsoPlainText">> #include “itkImageFileWriter.h”</p>
<p class="MsoPlainText">> #include "itkLineConstIterator.h"</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> #include "itkImage.h"</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> int main(int argc, char *argv[])</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> {</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> if( argc < 2 )</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> {</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> std::cerr << "Usage: "
<< std::endl;</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> std::cerr << argv[0]
<< " outputImageFile " << std::endl;</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> return EXIT_FAILURE;</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> }</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> typedef
itk::Image<unsigned char, 2> ImageType;</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> ImageType::Pointer image =
ImageType::New();</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> typedef itk::Image<unsigned
char, 2> ImageType;</p>
<p class="MsoPlainText">> ImageType::Pointer image =
ImageType::New();</p>
<p class="MsoPlainText">> typedef
itk::ImageFileWriter<ImageType> FileWriterType;</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> typedef
itk::LineConstIterator< ImageType > LineIteratorType;</p>
<p class="MsoPlainText">> ImageType::IndexType point0;</p>
<p class="MsoPlainText">> point0[0] = 46;</p>
<p class="MsoPlainText">> point0[1] = 232;</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> ImageType::IndexType point1;</p>
<p class="MsoPlainText">> point1[0] = 433;</p>
<p class="MsoPlainText">> point1[1] = 477;</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> LineIteratorType it( image,
point0, point1);</p>
<p class="MsoPlainText">> it.GoToBegin();</p>
<p class="MsoPlainText">> while (!it.IsAtEnd())</p>
<p class="MsoPlainText">> {</p>
<p class="MsoPlainText">> std::cout <<
(float)it.Get() << std::endl;</p>
<p class="MsoPlainText">> ++it;</p>
<p class="MsoPlainText">> }</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> FileWriterType::Pointer writer=
FileWriterType::New();</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">>
writer->SetFileName(argv[1]);</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> writer->SetInput(image);</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> writer->Update();</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> cout<<"--->line
iterator passed "<<endl;</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> return EXIT_SUCCESS;</p>
<p class="MsoPlainText">> }</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText"> </p>
<p class="MsoPlainText">I am in a confusion of setting the input
here “writer->SetInput(image);” . Could someone please
help me out ?
</p>
<p class="MsoPlainText">I am using InsightToolkit-4.1.0 with
Visual Studio 2010 on Windows 7.</p>
<p class="MsoPlainText"> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> Regards,</p>
<p class="MsoPlainText">> </p>
<p class="MsoPlainText">> Ravi Teja.</p>
<p class="MsoNormal"> </p>
</div>
<br>
<hr>
<font color="Gray" face="Arial" size="1">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.<br>
</font>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_____________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>
Visit other Kitware open-source projects at
<a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Kitware offers ITK Training Courses, for more information visit:
<a class="moz-txt-link-freetext" href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a>
Please keep messages on-topic and check the ITK FAQ at:
<a class="moz-txt-link-freetext" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>
</pre>
</blockquote>
<br>
<div style="bottom: auto; left: 228px; right: auto; top: 233px;
display: none;" class="translator-theme-default"
id="translator-floating-panel">
<div title="Zum übersetzen klicken"
id="translator-floating-panel-button"></div>
</div>
</body>
</html>