Thanks Dan. My code is attached, and the input image is found at the following URL: <div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><a href="http://i.imgur.com/wd3Yt.jpg" target="_blank" style="color: rgb(28, 81, 168); ">http://i.imgur.com/wd3Yt.jpg</a></span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">Let me know if you want my output along the way to help troubleshoot. Appreciate it-</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">-Ryan</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">CODE</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">===========================================================================================</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><div>
if (argc < 4)</div><div> {</div><div> std::cout << "./<binary> <input-file> <output-file> <ball-kernel-radius>\n";</div><div> return EXIT_FAILURE;</div><div> }</div><div>
<br></div><div> typedef itk::Image<float, 2> ImageType;</div><div> typedef itk::ImageFileReader<ImageType> ReaderType;</div><div> typedef itk::ImageFileWriter<ImageType> WriterType;</div><div> typedef itk::BinaryBallStructuringElement<float, 2> KernelType;</div>
<div> typedef itk::WhiteTopHatImageFilter<ImageType, ImageType, KernelType> FilterType;</div><div><br></div><div> ReaderType::Pointer r = ReaderType::New();</div><div> r->SetFileName(argv[1]);</div><div> try</div>
<div> {</div><div> r->Update();</div><div> }</div><div> catch (itk::ExceptionObject &e)</div><div> {</div><div> std::cerr << e << std::endl;</div><div> return EXIT_FAILURE;</div><div> }</div>
<div><br></div><div> ImageType::Pointer image = r->GetOutput();</div><div> KernelType kernel;</div><div> kernel.SetRadius(atoi(argv[3]));</div><div> kernel.CreateStructuringElement();</div><div> FilterType::Pointer filter = FilterType::New();</div>
<div> filter->SetKernel(kernel);</div><div> filter->SetInput(image);</div><div> try</div><div> {</div><div> filter->Update();</div><div> }</div><div> catch (itk::ExceptionObject &e)</div><div> {</div>
<div> std::cerr << e << std::endl;</div><div> return EXIT_FAILURE;</div><div> }</div><div><br></div><div> WriterType::Pointer w = WriterType::New();</div><div> w->SetFileName(argv[2]);</div><div> w->SetInput(filter->GetOutput());</div>
<div> try</div><div> {</div><div> w->Update();</div><div> }</div><div> catch (itk::ExceptionObject &e)</div><div> {</div><div> std::cerr << e << std::endl;</div><div> return EXIT_FAILURE;</div>
<div> }</div><div><br></div><div> // ITK Binary Threshold </div><div> typedef itk::BinaryThresholdImageFilter < ImageType, ImageType > ThreshFilterType; </div><div> ThreshFilterType::Pointer thresh_filter = ThreshFilterType::New(); </div>
<div> thresh_filter->SetInsideValue( 255 ); </div><div> thresh_filter->SetOutsideValue( 0 ); </div><div> thresh_filter->SetLowerThreshold( 35 ); </div><div> thresh_filter->SetUpperThreshold( 255 ); </div><div>
thresh_filter->SetInput( filter->GetOutput() ); </div><div><br></div><div> WriterType::Pointer w2 = WriterType::New();</div><div> w2->SetFileName(argv[4]);</div><div> w2->SetInput(thresh_filter->GetOutput()); </div>
<div> try</div><div> {</div><div> w2->Update();</div><div> }</div><div> catch (itk::ExceptionObject &e)</div><div> {</div><div> std::cerr << e << std::endl;</div><div> return EXIT_FAILURE;</div>
<div> }</div><div><br></div><div> typedef itk::SignedMaurerDistanceMapImageFilter <</div><div>ImageType, ImageType ></div><div>itkSignedMaurerDistanceMapImageFilterType;</div><div>itkSignedMaurerDistanceMapImageFilterType::Pointer distFilter</div>
<div>= itkSignedMaurerDistanceMapImageFilterType::New ();</div><div> </div><div><br></div><div>distFilter->SetInput(thresh_filter->GetOutput());</div><div>distFilter->SetInsideIsPositive(true);</div><div> distFilter->Update();</div>
<div><br></div><div> w2->SetFileName(argv[5]);</div><div> w2->SetInput(distFilter->GetOutput());</div><div> try</div><div> {</div><div> w2->Update();</div><div> }</div><div> catch (itk::ExceptionObject &e)</div>
<div> {</div><div> std::cerr << e << std::endl;</div><div> return EXIT_FAILURE;</div><div> }</div><div><br></div><div> typedef itk::RegionalMaximaImageFilter <</div><div>ImageType, ImageType ></div>
<div>itkRegionalMaximaImageFilterFilterType;</div><div>itkRegionalMaximaImageFilterFilterType::Pointer rmFilter</div><div>= itkRegionalMaximaImageFilterFilterType::New ();</div><div> </div><div><br></div><div>rmFilter->SetInput(distFilter->GetOutput());</div>
<div><br></div><div> rmFilter->Update();</div><div><br></div><div><br></div><div> w2->SetFileName(argv[6]);</div><div> w2->SetInput(rmFilter->GetOutput());</div><div> try</div><div> {</div><div> w2->Update();</div>
<div> }</div><div> catch (itk::ExceptionObject &e)</div><div> {</div><div> std::cerr << e << std::endl;</div><div> return EXIT_FAILURE;</div><div> }</div><div><br></div><div><br></div><div><br></div>
<div>return EXIT_SUCCESS;</div><div>}</div><div><br></div></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><br></span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></font></div><div><a href="http://i.imgur.com/wd3Yt.jpg" target="_blank" style="color: rgb(28, 81, 168); "></a><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></font><br><div class="gmail_quote">On Tue, Sep 14, 2010 at 1:15 AM, Dan Mueller <span dir="ltr"><<a href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Ryan,<br>
<br>
Indeed, I computed the regional maxima of the distance map.<br>
<br>
Perhaps you could post your code (or a minimal example) and input data?<br>
<font color="#888888"><br>
Dan<br>
</font><div><div></div><div class="h5"><br>
On 13 September 2010 22:50, Ryan Smith <<a href="mailto:ryanleesmith@gmail.com">ryanleesmith@gmail.com</a>> wrote:<br>
> Hi Dan-<br>
> My itkSignedMaurerDistanceMapImageFilter now matches your output (I invoked<br>
> the SetInsideIsPositive(true); method as my initial result was the inverse<br>
> of yours). With that said, my RegionalMaxima filter is not producing<br>
> quality results. You are sending the distance map output to the to the<br>
> RegionalMaxima filter, not any of the other results in the chain, right?<br>
> Upon saving the output of my RegionalMaximaImageFilter to disk I cannot<br>
> open the mha file with any of the readers I use. I get an error. Any idea<br>
> on where I am going wrong? I think I am close, however this one has me<br>
> stumped. Thanks again for your continued support-<br>
> -Ryan<br>
><br>
> On Fri, Aug 20, 2010 at 11:05 PM, Dan Mueller <<a href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>> wrote:<br>
>><br>
>> Hi Ryan,<br>
>><br>
>> It looks like you have a problem with pixel type. Consider using a<br>
>> real pixel type (eg. float or double).<br>
>><br>
>> HTH<br>
>><br>
>> Cheers, Dan<br>
>><br>
>> On 20 August 2010 22:06, Ryan Smith <<a href="mailto:ryanleesmith@gmail.com">ryanleesmith@gmail.com</a>> wrote:<br>
>> > Thanks again for all the help Dan. I tried your suggestion for using<br>
>> > the itkSignedMaurerDistanceMapImageFilter and got different results. I<br>
>> > sent<br>
>> > in my BinaryThresholdImageFilter output and got the following from<br>
>> > my itkSignedMaurerDistanceMapImageFilter<br>
>> > <a href="http://i.imgur.com/jZ1AN.png" target="_blank">http://i.imgur.com/jZ1AN.png</a><br>
>> ><br>
>> > Are there any other inputs I need to set for my Mauerer Distance Map?<br>
>> > This<br>
>> > one is new to me and I didn't find much in the documentation. Thanks-<br>
>> > -Ryan<br>
>> > p.s. You were right about my previous lossy compression woes<br>
>> > On Thu, Aug 19, 2010 at 2:51 PM, Dan Mueller <<a href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>> wrote:<br>
>> >><br>
>> >> Hi Ryan,<br>
>> >><br>
>> >> 1. The output of the connected component filter you provided does not<br>
>> >> seem right. Are you doubly sure you are passing the binary image to<br>
>> >> the connected component filter? I have attached the output you should<br>
>> >> get.<br>
>> >><br>
>> >> 2. That said, if you just need to extract seeds for further<br>
>> >> processing, I don't think you need to use the connected component<br>
>> >> filter. This filter simply assigns a unique identifier (Eg. 1, 2, 3,<br>
>> >> 4, etc) to each component or "blob" in the image. One way of obtaining<br>
>> >> seeds is to take the binary image, compute the distance transform (try<br>
>> >> Code/BasicFilters/itkSignedMaurerDistanceMapImageFilter.h), and the<br>
>> >> apply the regional maxima filter<br>
>> >> (Code/Review/itkRegionalMaximaImageFilter.h). I have attached the<br>
>> >> output from this chain.<br>
>> >><br>
>> >> HTH<br>
>> >><br>
>> >> Cheers, Dan<br>
>> >><br>
>> >> On 19 August 2010 21:20, Ryan Smith <<a href="mailto:ryanleesmith@gmail.com">ryanleesmith@gmail.com</a>> wrote:<br>
>> >> > Hi Dan-<br>
>> >> > The white top hat worked great at removing my extra features, and the<br>
>> >> > binary<br>
>> >> > thresholding cleaned everything else up, however I am still having<br>
>> >> > some<br>
>> >> > trouble using the ConnectedComponentFilter. I found this article<br>
>> >> > which<br>
>> >> > is<br>
>> >> > trying to do exactly what I am attempting:<br>
>> >> > <a href="http://www.itk.org/pipermail/insight-users/2007-January/020532.html" target="_blank">http://www.itk.org/pipermail/insight-users/2007-January/020532.html</a><br>
>> >> > I want the position and full width half max (FWHM) of each intensity<br>
>> >> > maxima<br>
>> >> > in the image. I tried using the connected component filter and got<br>
>> >> > the<br>
>> >> > output found at the following URL: <a href="http://i.imgur.com/TCqL8.png" target="_blank">http://i.imgur.com/TCqL8.png</a><br>
>> >> > It appears each feature is being tagged as several different<br>
>> >> > features.<br>
>> >> > Just<br>
>> >> > to confirm I am sending the binary thresholded image, not the<br>
>> >> > original Gaussian spot image into the ConnectedComponentFilter.<br>
>> >> > I feel like I am going down the wrong path here. I don't necessarily<br>
>> >> > need<br>
>> >> > to segment my points, I just need to clean up the image (done) and<br>
>> >> > potentially use techniques such as those in other ITK problems I have<br>
>> >> > read<br>
>> >> > to find 'seed points' for some region growing algorithms based on the<br>
>> >> > intensity maxima of my image. Any thoughts? Thanks in advance-<br>
>> >> > -Ryan<br>
>> >> ><br>
>> >> ><br>
>> >> > On Sun, Aug 15, 2010 at 11:22 PM, Dan Mueller <<a href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>><br>
>> >> > wrote:<br>
>> >> >><br>
>> >> >> Hi Ryan,<br>
>> >> >><br>
>> >> >> You might consider using the "white top hat" operation to remove the<br>
>> >> >> background:<br>
>> >> >> WhiteTopHat = I - Dilate( Erode(I) )<br>
>> >> >> where I is the image, Erode is morphological erosion, and Dilate is<br>
>> >> >> morphological dilation.<br>
>> >> >><br>
>> >> >> You can find an implementation of this operation in:<br>
>> >> >> Code/BasicFilters/itkWhiteTopHatImageFilter.h<br>
>> >> >><br>
>> >> >> Once the background is removed, a simple global intensity threshold<br>
>> >> >> should suffice to segment the spots. The following filters may be<br>
>> >> >> helpful for that task:<br>
>> >> >> Code/BasicFilters/itkBinaryThresholdImageFilter.h<br>
>> >> >> Code/Algorithms/itkOtsuThresholdImageFilter.h<br>
>> >> >> Code/Review/itkKappaSigmaThresholdImageFilter.h<br>
>> >> >><br>
>> >> >> HTH<br>
>> >> >><br>
>> >> >> Cheers, Dan<br>
>> >> >><br>
>> >> >> On 15 August 2010 23:04, Ryan Smith <<a href="mailto:ryanleesmith@gmail.com">ryanleesmith@gmail.com</a>> wrote:<br>
>> >> >> > Hi-<br>
>> >> >> > I am attempting to remove the background and detect features in<br>
>> >> >> > the<br>
>> >> >> > following image:<br>
>> >> >> > <a href="http://i.imgur.com/wd3Yt.jpg" target="_blank">http://i.imgur.com/wd3Yt.jpg</a><br>
>> >> >> ><br>
>> >> >> > I have a series of images in which the white circular spots travel<br>
>> >> >> > and<br>
>> >> >> > the<br>
>> >> >> > white vertical stripes remain stationary. I would like to apply<br>
>> >> >> > some<br>
>> >> >> > simple<br>
>> >> >> > background subtraction to remove the white stripes then autodetect<br>
>> >> >> > the<br>
>> >> >> > intensity maxima associated with the circular features.<br>
>> >> >> ><br>
>> >> >> > A brief search provided the following results which address<br>
>> >> >> > similar<br>
>> >> >> > problems<br>
>> >> >> > using itkConnectedComponentFilter. Is this what I want after my<br>
>> >> >> > background<br>
>> >> >> > is subtracted? Any example code on how to get the location and<br>
>> >> >> > sizes<br>
>> >> >> > of<br>
>> >> >> > the<br>
>> >> >> > components? Thanks in advance-<br>
>> >> >> ><br>
>> >> >> > -Ryan<br>
>> >> >> ><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>
><br>
><br>
</div></div></blockquote></div><br></div>