What's the value of your label? In your previous code, the output of the add filter is set to unsigned char, so you may have typecasting issues as David alluded to.<div><br></div><div>Your current code looks okay to me. Try writing bwImage to disk to determine if there is an ITK or VTK issue.</div>
<div><br><br><div class="gmail_quote">On Thu, Feb 10, 2011 at 3:15 PM, Sara Rolfe <span dir="ltr"><<a href="mailto:smrolfe@u.washington.edu" target="_blank">smrolfe@u.washington.edu</a>></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">I'm attaching my code. The rescale intensity filter worked great to get the image data in the right right range. But I'm still having a problem when I try to add the regions which will be labeled with color. I move the data into the intensity range 100-200, and then use the add image filter to add the labeled image on top, so that I can use a piecewise colormap in VTK to apply colors to these values. I think the add images may be where the problem is. What I would rather do is mask the image with the labels so that the pixels in the image were replaced with the label value for all non-zero labels. Is there anything like this implemented, or would I need to go through pixel by pixel and change the values? I've only seen binary mask filters.<div>
<br></div><div>Thanks,</div><div>Sara</div><font color="#888888"><div><br></div><div></div></font></div><br><div style="word-wrap:break-word"><div><br><div><div><br><div><div>On Feb 10, 2011, at 10:56 AM, David Doria wrote:</div>
<br><blockquote type="cite"><div class="gmail_quote">On Thu, Feb 10, 2011 at 1:38 PM, Sara Rolfe <span dir="ltr"><<a href="mailto:smrolfe@u.washington.edu" target="_blank">smrolfe@u.washington.edu</a>></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'm attempting to overlay an image with color. I've had trouble finding documentation on this, either in ITK or VTK. The way I'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'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'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'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->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->SetInput( imageInverter->GetOutput() );</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="white-space:pre-wrap">        </span>subFilter->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>Can you provide a compilable code snippet? I'm also not sure what you mean by "overlay with color"?</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"><a href="http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/RescaleIntensityImageFilter" target="_blank">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" target="_blank"></a><br clear="all">David </div></blockquote></div><br></div></div></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<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>
</div>