[Insight-users] About Hough Circle Filter and PNG file

Jiangtao Li nelfylee at gmail.com
Wed May 5 00:00:21 EDT 2010


Dear All,


When I use below code to save sampled image as a PNG file (RGBA), and then
read it again, the Hough Circle Filter works!

I found Hough Filter only support the image pixel has 4 components, well, if
so, I will change my image to 4 components first,

I change it back to Gray image by RGBToLuminanceImageFilter for Hough
filter, however, Hough filter gives wrong result again.


typedef itk::Image<itk::RGBAPixel<unsigned char>> RGBAImage;
 typedef itk::ComposeRGBAImageFilter<ImageUChar2D, RGBAImage>
ComposeRGBAImageFilter;
ComposeRGBAImageFilter::Pointer rgba = ComposeRGBAImageFilter::New();
  rgba->SetInput(0, resampler->GetOutput());
rgba->SetInput(1, resampler->GetOutput());
 rgba->SetInput(2, resampler->GetOutput());
rgba->SetInput(3, dup->GetOutput());
  rgba->Update();

// typedef itk::ImageFileWriter<RGBAImage> ImageFileWriter2;
// ImageFileWriter2::Pointer writer = ImageFileWriter2::New();
// writer->SetInput(rgba->GetOutput());
// writer->SetFileName("E:/Resample.png");
// writer->Update();

// typedef itk::ImageFileReader<ImageUChar2D> ImageFileReader;
// ImageFileReader::Pointer reader = ImageFileReader::New();
// reader->SetFileName("E:/Resample.png");
// reader->Update();

typedef itk::RGBToLuminanceImageFilter<RGBAImage, ImageUChar2D>
RGBToLuminanceImageFilter;
RGBToLuminanceImageFilter::Pointer rgba2gray =
RGBToLuminanceImageFilter::New();
 rgba2gray->SetInput(rgba->GetOutput());
rgba2gray->Update();

typedef itk::HoughTransform2DCirclesImageFilter<unsigned char, float>
HoughTransformFilterType;
HoughTransformFilterType::Pointer hough = HoughTransformFilterType::New();

hough->SetInput(rgba2gray->GetOutput());
hough->SetNumberOfCircles(1);
 hough->SetMinimumRadius(10);
hough->SetMaximumRadius(300);
hough->SetVariance(5);
 hough->SetSigmaGradient(1);
hough->SetDiscRadiusRatio(2);
hough->Update();



Any ideas? I really need your help. thank you very much !


Best Regards!



Jiangtao

-- 


More information about the Insight-users mailing list