<div class="gmail_quote">On Thu, Feb 10, 2011 at 1:38 PM, Sara Rolfe <span dir="ltr">&lt;<a href="mailto:smrolfe@u.washington.edu">smrolfe@u.washington.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word">Hello,<div><br></div><div>I&#39;m attempting to overlay an image with color.  I&#39;ve had trouble finding documentation on this, either in ITK or VTK.  The way I&#39;m going about it is to scale the values of the image down and then use the add image filter to add the labels on top.  I could then use VTK to create a corresponding colormap.</div>
<div><br></div><div>However, I&#39;m getting stuck on something that should be very simple.  My operations to combine the two images are failing.  I think the problem is the <span style="font-family:Monaco;font-size:10px">SubtractConstantFromImageFilter.  </span>I&#39;ve checked the output and it looks like the constant is not being subtracted.  The input to this filter is an image with a value of 0 for the background and 255 for the object.  I&#39;d like to change these to 0 and 1.  The pixel type is unsigned char.  I use the following:</div>
<div><span style="font-family:Monaco;font-size:10px"><br></span></div><div><span style="font-family:Monaco;font-size:10px"><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="white-space:pre-wrap">        </span>SubFilterType::Pointer subFilter = SubFilterType::New();</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="white-space:pre-wrap">        </span>InputPixelType subValue = <span style="color:#1c00cf">254</span>;</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<span style="white-space:pre-wrap">        </span>subFilter-&gt;SetConstant(subValue);</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="white-space:pre-wrap">        </span>subFilter-&gt;SetInput( imageInverter-&gt;GetOutput() );</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="white-space:pre-wrap">        </span>subFilter-&gt;Update();</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<br></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><font face="Helvetica"><span style="font-size:medium">But the output image is still 0 - 255.  Am I missing something simple?  </span></font></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><font face="Helvetica"><span style="font-size:medium"><br></span></font></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<font face="Helvetica"><span style="font-size:medium">Also, is there a better way to accomplish this task, or any examples showing something similar?</span></font></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<font face="Helvetica"><span style="font-size:medium"><br></span></font></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><font face="Helvetica"><span style="font-size:medium">Thanks,</span></font></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><font face="Helvetica"><span style="font-size:medium">Sara</span></font></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<font face="Helvetica"><span style="font-size:medium"><br></span></font></div></span></div></div></blockquote><meta http-equiv="content-type" content="text/html; charset=utf-8">Can you provide a compilable code snippet? I&#39;m also not sure what you mean by &quot;overlay with color&quot;?</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">Something that jumps out is that if you subtract 254 from an unsigned char you will be assigning a negative value to an unsigned char which is undefined.</div><div class="gmail_quote">
<br></div><div class="gmail_quote">If all you are trying to do is map (0-255) to (0-1) you could use itkRescaleIntensityImageFilter</div><div class="gmail_quote"><meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/RescaleIntensityImageFilter">http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/RescaleIntensityImageFilter</a></div>
<div class="gmail_quote"><a href="http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/RescaleIntensityImageFilter"></a><br clear="all">David </div>