<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">Hello all,</span></font><div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">I am relative new to ITK, so bare with me...</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">I am working on a registration project and I would like to take the difference between an image slice and a resulting image taken from a volume after registration done.  In essence, a pixel-by-pixel subtraction.</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">The itk::SquaredDifferenceImageFilter is currently being used to determine the difference image.  However, when pixel-values are reviewed in the resulting image, large negative values are found.  It is believed these negative values are due to the use of the SHORT data-type to represent the pixel-type.  The squared-operation of the filter obviously handles negative subtraction results;  likely to occur regardless of the order in which the two images are given to this filter.</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">Is the use of the SHORT data-type likely responsible for these negative pixel-values?  Changing the type is not an option.</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">Reading through the ITK Software Guide (Version 2.4), I came across the itk::SubtractImageFilter topic in Section 8.2, "Hello World" Registration, page 323.  In this section it says,</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">"... the use of subtraction as a method for comparing the images is appropriate here b<span class="Apple-style-span" style="font-family: Helvetica; font-size: 12px; "><font style="font: 10.0px Times"><font class="Apple-style-span" face="'Courier New'" size="5">ecause we chose to represent the images using a pixel type </font></font><font style="font: 10.0px Courier"><font class="Apple-style-span" face="'Courier New'" size="5">float</font></font><font style="font: 10.0px Times"><font class="Apple-style-span" face="'Courier New'" size="5">.  A different filter would ha<span class="Apple-style-span" style="font-family: Helvetica; font-size: 12px; "><font style="font: 10.0px Times"><font class="Apple-style-span" face="'Courier New'" size="5">ve been used if the pixel type of the images were any of the </font></font><font style="font: 10.0px Courier"><font class="Apple-style-span" face="'Courier New'" size="5">unsigned </font></font><font style="font: 10.0px Times"><font class="Apple-style-span" face="'Courier New'" size="5">integer type."</font></font></span></font></font></span></span></font></div><div><br></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">The difference is defined, with reference to respective class documentation, as "Output = Input1 - Input2" for the itk::SubtractImageFilter.  With this in mind, and the fact that the pixel-values across the entire image for "Input2" will likely not be less than the respective pixels in "Input1", can I directly apply the itk::SubtractImageFilter in this case?</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">Thank you,</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">Michael.</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;">Robarts Research.</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div></div></body></html>