<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><br>Jothy<br> <br><br><div class="gmail_quote">
On Tue, Oct 11, 2011 at 9:17 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com">daviddoria@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 class="im">On Mon, Oct 10, 2011 at 11:41 AM, Martijn Steenwijk<br>
<<a href="mailto:martijnsteenwijk@gmail.com">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><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>