<br>Hi Luis et al.,<br><br>I'm puzzled by the intensityThreshold, because the optimizer observer gives:<br><br>Using fixed image intensity threshold: 1<br><br>0 nan [nan, nan, nan]<br>1 nan [nan, nan, nan]<br>2 nan [nan, nan, nan]<br>
3 nan [nan, nan, nan]<br>4 nan [nan, nan, nan]<br>5 nan [nan, nan, nan]<br>6 nan [nan, nan, nan]<br>7 nan [nan, nan, nan]<br>8 nan [nan, nan, nan]<br>9 nan [nan, nan, nan]<br>10 nan [nan, nan, nan]<br>
11 nan [nan, nan, nan]<br>12 nan [nan, nan, nan]<br>13 nan [nan, nan, nan]<br>14 nan [nan, nan, nan]<br>15 nan [nan, nan, nan]<br>16 nan [nan, nan, nan]<br>17 nan [nan, nan, nan]<br>18 nan [nan, nan, nan]<br>
19 nan [nan, nan, nan]<br>20 nan [nan, nan, nan]<br><br><br>I'll try to explore a little more using the <br><br>BinaryThresholdImageFilter<br><br>I'll take a look at<br><br>examples/Filtering/BinaryThresholdImageFilter.cxx<br>
<br>Thanks,<br>Darren<br><br><br><br><div class="gmail_quote">On Wed, Mar 17, 2010 at 3:44 PM, Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Darren,<br>
<br>
Excellent,<br>
<br>
In that case you should be able to eliminate the background<br>
by using:<br>
<br>
intensityThreshold = 1;<br>
metric->SetFixedImageSamplesIntensityThreshold( intensityThreshold );<br>
<br>
If you want to be 100% sure, it may be worth running a<br>
BinaryThresholdImageFilter first and saving the output<br>
for further visualization. That will provide a good sanity<br>
check.<br>
<br>
<br>
Regards,<br>
<br>
<br>
Luis<br>
<br>
<br>
------------------------------------------------------------------------------------------<br>
On Wed, Mar 17, 2010 at 5:22 PM, Darren Weber<br>
<div><div></div><div class="h5"><<a href="mailto:darren.weber.lists@gmail.com">darren.weber.lists@gmail.com</a>> wrote:<br>
><br>
> Hi Luis et al.,<br>
><br>
> I've created the input images by exporting from Photoshop with a defined<br>
> background value (RGB: 0 0 0). It's these values that I want to exclude<br>
> from the metric in the image registration method.<br>
><br>
> The min color is confirmed by the identify program of ImageMagick:<br>
><br>
> Colorspace: RGB<br>
> Depth: 16-bit<br>
> Channel depth:<br>
> gray: 16-bit<br>
> Channel statistics:<br>
> Gray:<br>
> min: 0 (0)<br>
> max: 46335 (0.707027)<br>
> mean: 25664.6 (0.391617)<br>
> standard deviation: 15257.7 (0.232818)<br>
> kurtosis: -0.857968<br>
> skewness: -0.771191<br>
><br>
><br>
> TIA,<br>
> Darren<br>
><br>
><br>
><br>
> On Tue, Mar 16, 2010 at 10:25 AM, Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>><br>
> wrote:<br>
>><br>
>> Hi Darren,<br>
>><br>
>> 1) As described in the ITK Software Guide<br>
>><br>
>> <a href="http://www.itk.org/ItkSoftwareGuide.pdf" target="_blank">http://www.itk.org/ItkSoftwareGuide.pdf</a><br>
>><br>
>> in the Chapter 7 "Reading and Writing Images",<br>
>> in section 7.1, pdf-page: 296:<br>
>><br>
>> ITK takes the pixel data from the input file and casts it to<br>
>> the PixelType that you used for instantiating your image<br>
>> at compilation time. The casting is performed using<br>
>> C-Language rules, and not truncation, overflow or underflow<br>
>> detection, nor scaling is applied.<br>
>><br>
>> So, if your TIFF file contains 16bit integers values per pixel<br>
>> and you instantiate the image using a "float" pixel type, then<br>
>> the values of the integers will be casted (without any rescaling)<br>
>> in to floats.<br>
>><br>
>><br>
>> 2) If you have a use for the original "16bits" data, then it may<br>
>> be worth reading the file in an image of the exact same type<br>
>> and then using a CastImageFilter to convert it to float.<br>
>><br>
>> On the other hand, if you only need the float image for<br>
>> performing the registration, then reading directly into a<br>
>> float image is actually saving you some memory.<br>
>><br>
>> 3) "Black" pixels is quite an ambiguous measure, since,<br>
>> depending on the image viewer that you are using, it may<br>
>> well be that what you "see" as black, is actually a level<br>
>> of intensity with values around 20,000 (for example).<br>
>><br>
>> What you really need is a sort of histogram that will allow<br>
>> you to identify the background of the image,<br>
>><br>
>> or<br>
>><br>
>> A visualization method that allows you to identify the<br>
>> intensity level of the background.<br>
>><br>
>> You may want to consider:<br>
>><br>
>> Insight/Code/Algorithms/<br>
>> itkOtsuThresholdImageCalculator.h<br>
>><br>
>> and the Insight Journal papers:<br>
>><br>
>> "Kappa Sigma Clipping"<br>
>> <a href="http://www.insight-journal.org/browse/publication/132" target="_blank">http://www.insight-journal.org/browse/publication/132</a><br>
>> <a href="http://hdl.handle.net/1926/367" target="_blank">http://hdl.handle.net/1926/367</a><br>
>><br>
>> "Robust Automatic Threshold Selection"<br>
>> <a href="http://www.insight-journal.org/browse/publication/134" target="_blank">http://www.insight-journal.org/browse/publication/134</a><br>
>> <a href="http://hdl.handle.net/1926/370" target="_blank">http://hdl.handle.net/1926/370</a><br>
>><br>
>> as options for estimating a suitable threshold.<br>
>><br>
>><br>
>><br>
>><br>
>> Regards,<br>
>><br>
>><br>
>> Luis<br>
>><br>
>><br>
>><br>
>> ----------------------------------------------------------------<br>
>> On Mon, Mar 15, 2010 at 3:09 PM, Darren Weber<br>
>> <<a href="mailto:darren.weber.lists@gmail.com">darren.weber.lists@gmail.com</a>> wrote:<br>
>> ><br>
>> > Hi Luis et al.,<br>
>> ><br>
>> > Now the ITK library is compiled and installed with the additional<br>
>> > features<br>
>> > available. Now this code will compile:<br>
>> ><br>
>> > typedef itk::MeanSquaresImageToImageMetric<iBWImgType,iBWImgType><br>
>> > MetricType;<br>
>> > MetricType::Pointer metric = MetricType::New();<br>
>> > metric->SetUseFixedImageSamplesIntensityThreshold( true );<br>
>> > metric->SetFixedImageSamplesIntensityThreshold( intensityThreshold );<br>
>> > //metric->SetUseSequentialSampling( true );<br>
>> > //metric->SetUseAllPixels( true );<br>
>> ><br>
>> ><br>
>> > Now a question arises about the range of values for the<br>
>> > "intensityThreshold". The input pixel and image typedefs are:<br>
>> ><br>
>> > const unsigned short dimImg = 2;<br>
>> > typedef float iPixType;<br>
>> > typedef itk::Image< iPixType, dimImg > iBWImgType;<br>
>> > typedef itk::ImageFileReader< iBWImgType > bwImageReaderType;<br>
>> ><br>
>> ><br>
>> > The image reader is pulling in .tif images, which ImageMagick identifies<br>
>> > as<br>
>> > (see verbose output in attachment):<br>
>> ><br>
>> > $ identify testdata/bw/section0003_w1.tif<br>
>> > testdata/bw/section0003_w1.tif TIFF 549x539 549x539+0+0 16-bit Grayscale<br>
>> > DirectClass 615KB 0.010u 0:00.030<br>
>> ><br>
>> > When this image is read into the iPixType, I assume the range of these<br>
>> > "unsigned short" values is mapped or cast into a range of "float"<br>
>> > values.<br>
>> > Is the new range of values from 0.0 to 1.0, is that correct for the<br>
>> > "float"<br>
>> > pixel type in ITK? How does the ITK image reader convert or cast the<br>
>> > pixel<br>
>> > values to float? (The reason the input images are specified as "float"<br>
>> > rather than "unsigned short" is to have them input to the registration<br>
>> > method as floats - should this be done with an explicit cast filter?)<br>
>> ><br>
>> > The input images have a black background (RGB value: 0 0 0). It would<br>
>> > be<br>
>> > great to threshold the MeanSquaresImageToImageMetric to exclude all the<br>
>> > black pixels. In the range of values for the input pixel data that are<br>
>> > an<br>
>> > unsigned short (0 to 65535), any pixel above 0 would be<br>
>> ><br>
>> > unsigned short intensityThreshold = 1;<br>
>> ><br>
>> > However, the intensityThreshold is declared and initialized as:<br>
>> ><br>
>> > iBWImgType::PixelType intensityThreshold = 0.0;<br>
>> ><br>
>> > Is this a reasonable value for this float intensityThreshold:<br>
>> ><br>
>> > iBWImgType::PixelType intensityThreshold = 1.0 / USHRT_MAX;<br>
>> ><br>
>> ><br>
>> > TIA,<br>
>> > Darren<br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > On Sat, Mar 6, 2010 at 12:15 PM, Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Hi Darren,<br>
>> >><br>
>> >> The feature that you are referring to, is only available<br>
>> >> in the new version of the metrics that are in the<br>
>> >> Code/Review directory.<br>
>> >><br>
>> >> In order to use this classes you must reconfigure your<br>
>> >> binary build of ITK, by rerunning CMake and turning<br>
>> >> ON the CMake variables:<br>
>> >><br>
>> >> * ITK_USE_REVIEW<br>
>> >> * OPTIMIZED_REGISTRATION_METHODS<br>
>> >><br>
>> >> Then you can rebuild your application.<br>
>> >><br>
>> >><br>
>> >> Regards,<br>
>> >><br>
>> >><br>
>> >> Luis<br>
>> >><br>
>> >><br>
>> >><br>
>> >><br>
>> >> -----------------------------------------------------------------------------------<br>
>> >> On Thu, Mar 4, 2010 at 5:56 PM, Darren Weber<br>
>> >> <<a href="mailto:darren.weber.lists@gmail.com">darren.weber.lists@gmail.com</a>> wrote:<br>
>> >> ><br>
>> >> > In an image registration framework, the metric determines image<br>
>> >> > "matches".<br>
>> >> > Let's suppose we have large images that contain a majority of<br>
>> >> > background<br>
>> >> > color (or transparency). In a metric like the<br>
>> >> > itk::MeanSquaresImageToImageMetric, the majority of the<br>
>> >> > sqaured-diff-values<br>
>> >> > would be zero and the remainder of the "relevant" pixel differences<br>
>> >> > may<br>
>> >> > be<br>
>> >> > "swamped" or "lost" in the division by a large N.<br>
>> >> > Also, it appears the default metric sampling is a random-sample of<br>
>> >> > the<br>
>> >> > image<br>
>> >> > pixels (this might be modified with methods like<br>
>> >> > "SetUseAllPixels(bool)").<br>
>> >> > In this case, it is possible, perhaps likely, that few of the<br>
>> >> > "relevant"<br>
>> >> > pixels will be evaluated in the metric.<br>
>> >> > See:<br>
>> >> ><br>
>> >> ><br>
>> >> > <a href="http://www.itk.org/Doxygen316/html/classitk_1_1ImageToImageMetric.html#42b876134388099afbf34b14faf83cdb" target="_blank">http://www.itk.org/Doxygen316/html/classitk_1_1ImageToImageMetric.html#42b876134388099afbf34b14faf83cdb</a><br>
>> >> > This documentation suggests there are also options to define:<br>
>> >> > IntensityThreshold, Masks, and SequentialSampling<br>
>> >> > In my reading of the doxy page (see next link), there is a method<br>
>> >> > called<br>
>> >> > "SetFixedImageSamplesIntensityThreshold" that might be useful to<br>
>> >> > define<br>
>> >> > a<br>
>> >> > background value (like zero) to be excluded from the metric. Is that<br>
>> >> > right?<br>
>> >> ><br>
>> >> ><br>
>> >> > <a href="http://www.itk.org/Doxygen316/html/classitk_1_1MeanSquaresImageToImageMetric-members.html" target="_blank">http://www.itk.org/Doxygen316/html/classitk_1_1MeanSquaresImageToImageMetric-members.html</a><br>
>> >> > What is the logic of this "threshold" method? From the<br>
>> >> > documentation,<br>
>> >> > it<br>
>> >> > appears to be a minima value. So if the background intensity is<br>
>> >> > zero,<br>
>> >> > the<br>
>> >> > threshold value of 1 would include all pixels > 0 (note the threshold<br>
>> >> > value<br>
>> >> > must be the same type as the fixed image PixelType).<br>
>> >> > There is no equivalent method for the moving image,<br>
>> >> > like "SetMovingImageSamplesIntensityThreshold". Is this unnecessary<br>
>> >> > because<br>
>> >> > the metric only scans the pixels of the moving image that fall within<br>
>> >> > the<br>
>> >> > "domain" of fixed image after the transform & interpolation?<br>
>> >> > I could not locate this method in the class hierarchy - is it<br>
>> >> > available<br>
>> >> > (inherited) in all metrics?<br>
>> >> > I'm confused because these methods do not appear to be available<br>
>> >> > to itk::MeanSquaresImageToImageMetric<br>
>> >> > e.g.: CODE:<br>
>> >> > typedef itk::MeanSquaresImageToImageMetric< iBWImgType,<br>
>> >> > iBWImgType ><br>
>> >> > MetricType;<br>
>> >> > MetricType::Pointer metric = MetricType::New();<br>
>> >> > metric->SetFixedImageSamplesIntensityThreshold( 0.0 );<br>
>> >> > metric->SetUseAllPixels( true );<br>
>> >> > e.g.: COMPILATION:<br>
>> >> > itkImageRigid2DCoregistration.cxx: In function ‘int main(int,<br>
>> >> > char**)’:<br>
>> >> > itkImageRigid2DCoregistration.cxx:442: error: ‘class<br>
>> >> > itk::MeanSquaresImageToImageMetric<iBWImgType, iBWImgType>’ has no<br>
>> >> > member<br>
>> >> > named ‘SetFixedImageSamplesIntensityThreshold’<br>
>> >> > itkImageRigid2DCoregistration.cxx:443: error: ‘class<br>
>> >> > itk::MeanSquaresImageToImageMetric<iBWImgType, iBWImgType>’ has no<br>
>> >> > member<br>
>> >> > named ‘SetUseAllPixels’<br>
>> >> > gmake[2]: ***<br>
>> >> ><br>
>> >> ><br>
>> >> > [CMakeFiles/itkImageRigid2DCoregistration.dir/itkImageRigid2DCoregistration.cxx.o]<br>
>> >> > Error 1<br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > TIA,<br>
>> >> > Darren<br>
>> >> ><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>
>> >> ><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br>