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"><<a href="mailto:rafayk_@hotmail.com" target="_blank">rafayk_@hotmail.com</a>></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,'Liberation Sans','DejaVu Sans',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,'Liberation Sans','DejaVu Sans',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,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',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,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',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">-></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<unsigned short, 2></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;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)"><vtkImageData></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)"><vtkImageData></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">-></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">-></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">-></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">-></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">-></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">-></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"><</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">*>(</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;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->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,'Liberation Sans','DejaVu Sans',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,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',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,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',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">-></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"><<</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)">"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"><<</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)">" 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"> 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"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">" 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"> 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"><<</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)">" z: "</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;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"><<</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"><<</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)">"Number of points: "</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"> 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;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"><<</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"><<</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)">"Number of cells: "</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"> 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;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"><<</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"><</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"><</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"><</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">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;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"><<</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)">"PIXEL LOC/VAL "</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">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"><<</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)">" "</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;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">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"><<</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,'Liberation Sans','DejaVu Sans',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,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',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,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',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)"><vtkImageCast></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)"><vtkImageCast></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">-></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">-></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">-></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">-></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,'Liberation Sans','DejaVu Sans',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,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',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,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',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)"><vtkPNGWriter></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)"><vtkPNGWriter></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">-></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">-></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">-></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->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">-></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,'Liberation Sans','DejaVu Sans',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>