How are you viewing the png image? Many png viewers cannot view 16 bit images.<div><br><br><div class="gmail_quote">On Wed, Mar 27, 2013 at 1:02 PM, Rafay Khan <span dir="ltr">&lt;<a href="mailto:rafayk_@hotmail.com" target="_blank">rafayk_@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr"><p style="margin-bottom:1em;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;line-height:18px">
I am doing some image processing using ITK and then using VTK to print the results in a .png format however, the output image is always black.</p><p style="margin-bottom:1em;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;line-height:18px">
Currently, I am converting itk::Image to vtk::vtkImageData using the itk::ImagetoVTKImageFilter(typedeffed to ITKtoVTKFilterType in my code).</p><pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:auto;max-height:600px;line-height:18px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif"><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">ITKtoVTKFilterType</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Pointer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> itk2vtkGray </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">ITKtoVTKFilterType</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">New</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
itk2vtkGray</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">SetInput</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">grayBinary</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">);</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">  </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:gray">//grayBinary is of type itk::Image&lt;unsigned short, 2&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
itk2vtkGray</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Update</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">

vtkSmartPointer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&lt;vtkImageData&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> grayVTK </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> vtkSmartPointer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&lt;vtkImageData&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">New</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">SetExtent</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">extent</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">);</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">SetSpacing</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">m_spacing</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">);</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">SetScalarTypeToUnsignedShort</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">SetNumberOfScalarComponents</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">1</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">);</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">AllocateScalars</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">DeepCopy</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">static_cast</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">vtkImageData</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">*&gt;(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">itk2vtkGray</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">GetOutput</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">()));</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:gray">//grayVTK = itk2vtkGray-&gt;GetOutput();</span></code></pre><p style="margin-bottom:1em;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;line-height:18px">
I have even confirmed that my VTK ImageData contains values of either 255 or 0 using the following code.</p><pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:auto;max-height:600px;line-height:18px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif"><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">int</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">*</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">dims </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">GetDimensions</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">

std</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">cout </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&quot;Dims: &quot;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&quot; x: &quot;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> dims</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">[</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">0</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">]</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&quot; y: &quot;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> dims</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">[</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">1</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">]</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&quot; z: &quot;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> dims</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">[</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">2</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">]</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> std</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">endl</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
std</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">cout </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&quot;Number of points: &quot;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">GetNumberOfPoints</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">()</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> std</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">endl</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
std</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">cout </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&quot;Number of cells: &quot;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">GetNumberOfCells</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">()</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> std</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">endl</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">

</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">for</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">int</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> y </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">0</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> y </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> dims</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">[</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">1</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">];</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> y</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">++)</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">{</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">        
     </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">for</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">int</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> x </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">0</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> x </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> dims</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">[</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">0</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">];</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> x</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">++)</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
     </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">{</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
         </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">unsigned</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">short</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">*</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">pixel </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">static_cast</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">unsigned</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,139)">short</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">*&gt;(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">GetScalarPointer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">x</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">,</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">y</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">,</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">0</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">));</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
         std</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">cout </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&quot;PIXEL LOC/VAL &quot;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> y</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">*</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">dims</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">[</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">0</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">]</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">+</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> x </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&quot; &quot;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> pixel</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">[</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">0</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">]</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">std</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">endl</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
     </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">}</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
     std</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">cout </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">&lt;&lt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> std</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">endl</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
 </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">}</span></code></pre><p style="margin-bottom:1em;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;line-height:18px">
I then go on to do an ImageCast to ensure the type of the data is unsignedShort.</p><pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:auto;max-height:600px;line-height:18px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif"><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">vtkSmartPointer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&lt;vtkImageCast&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> cast2 </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> vtkSmartPointer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&lt;vtkImageCast&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">New</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
cast2</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">SetInput</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">grayVTK</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">);</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
cast2</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">SetOutputScalarTypeToUnsignedShort</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
cast2</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">ClampOverflowOn</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
cast2</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Update</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span></code></pre>
<p style="margin-bottom:1em;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;line-height:18px">Then finally I use vtkPNGwriter to output the .png files. Notice that I have tried to output both the actual vtkImageData as well as output from the ImageCastFilter.</p>
<pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:auto;max-height:600px;line-height:18px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif"><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">vtkSmartPointer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&lt;vtkPNGWriter&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> writer </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
vtkSmartPointer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">&lt;vtkPNGWriter&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">::</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">New</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
writer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">SetFileName</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">filename</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">toStdString</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">().</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">c_str</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">());</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
writer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">SetInputConnection</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">cast2</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">GetOutputPort</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">());</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:gray">//writer-&gt;SetInput(grayVTK); I have tried to method as well but to no success</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
writer</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-&gt;</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(43,145,175)">Write</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">();</span></code></pre>
<p style="margin-bottom:1em;border:0px;font-size:14px;vertical-align:baseline;clear:both;word-wrap:break-word;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;line-height:18px">However, the .png output is always black. Does anyone know what I am doing wrong.</p>
                                               </div></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div>