<div dir="ltr">There was some wrong type casting. works now!<br><br>Thanks<br><br>Jothy<br><br><div class="gmail_quote">On Wed, Oct 12, 2011 at 11:16 AM, Jothy <span dir="ltr"><<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div dir="ltr">Hi David,<br><br>With GetScalarPointer<x,y,z) I get the address.<br><br>But I have to add to a std::vector<double>.<br>
<br>I tried like this<br><br>std::vector<double>result;<br><span style="color:#c0c0c0"> </span><span style="color:#808000">double</span><span style="color:#c0c0c0"> </span><span style="color:#000000">*</span>pixel<span style="color:#000000">=</span><span style="color:#808000">static_cast</span><span style="color:#000000"><</span><span style="color:#808000">double</span><span style="color:#000000">*>(</span>img<span style="color:#000000">-></span>GetScalarPointer<span style="color:#000000">(x,y,z</span><span style="color:#000000">));</span><span style="color:#c0c0c0"> </span><span style="color:#808000"><br>
</span><span style="color:#000000"></span>result<span style="color:#000000">.</span>push_back<span style="color:#000000">(</span>pixel<span style="color:#000000">[</span><span style="color:#000080">0</span><span style="color:#000000">]);</span><br>
<br>Its only pushing the address of the pointer, how to copy the value of the pointer?<br><br>I have just started c++ and pointer seem to be useful but tricky!<br><br>Thanks<br><font color="#888888"><br>Jothy<br> <br><br>
</font><div class="gmail_quote"><div class="im">
On Tue, Oct 11, 2011 at 9:17 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>></span> wrote:<br></div><div><div></div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Mon, Oct 10, 2011 at 11:41 AM, Martijn Steenwijk<br>
<<a href="mailto:martijnsteenwijk@gmail.com" target="_blank">martijnsteenwijk@gmail.com</a>> wrote:<br>
> You might be looking for an iterator, something like this:<br>
> reader->Update();<br>
> ImagePointer img = reader->GetOutput();<br>
> ImageIteratorType img_it(img, img->GetLargestPossibleRegion() );<br>
> for(img_it.GoToBegin(); !img_it.IsAtEnd(); ++img_it){<br>
> double value = img_it.Get();<br>
> }<br>
> Best,<br>
> Martijn<br>
<br>
</div>Martijn, this is the VTK list :)<br>
<br>
Jothy, I think you're looking for imageData->GetScalarPointer(). Then<br>
you can access the data with normal pointer arithmetic.<br>
<font color="#888888"><br>
David<br>
</font></blockquote></div></div></div><br><br clear="all"><div class="im"><br>-- <br><div dir="ltr">Jothybasu K Selvaraj<br>PhD Student<br>University of Liverpool<br>Liverpool,UK<br></div><br>
</div></div>
</blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Jothybasu K Selvaraj<br>PhD Student<br>University of Liverpool<br>Liverpool,UK<br></div><br>
</div>