[Insight-users] Questions about computing distance map using FastMarchingImageFilter
siyi ding
no16sylvan at hotmail.com
Fri Oct 2 02:43:22 EDT 2009
Dear all,
I am trying to use the FastMarchingImageFilter to compute the distance map of a canny edge image. I could get correct distance map when I follow the example - just give one seed point. However, when I add all the none zero points(about 9000 points) in the canny image as seeds, the program becomes very slow and the result does not look like a correct distance map. Is there any one who could help about this?
Thanks a lot.
//////////////////////////////////////////////////////
seeds->Initialize();
NodeType node;
const double seedValue = 0.0;
int num_seeds = 0;
// If we only use one seed as below, we get the correct distance map of that point.
/*
OutputImageType::IndexType seedPosition;
seedPosition[0] = 100;
seedPosition[1] = 100;
node.SetValue( seedValue );
node.SetIndex( seedPosition );
seeds->InsertElement(num_seeds++, node );
*/
// If we use all the nonzeros points in the canny edge image as seeds,we can not get correct distance map and the program is slow.
for (int i = 0; i< (image->w());i++)
for (int j = 0; j< (image->h());j++)
{
OutputImageType::IndexType seedPosition;
seedPosition[0] = i;
seedPosition[1] = j;
if ( (CannyFilter->GetOutput()->GetPixel(seedPosition))>0)
{
node.SetValue( seedValue );
node.SetIndex( seedPosition );
seeds->InsertElement(num_seeds++, node );
}
}
fastMarching->SetTrialPoints( seeds );
fastMarching->SetSpeedConstant(1.0);
fastMarching->SetOutputSize( CannyFilter->GetOutput()->GetBufferedRegion().GetSize() );
fastMarching->SetOutputOrigin ( CannyFilter->GetOutput()->GetOrigin());
fastMarching->SetOutputSpacing ( CannyFilter->GetOutput()->GetSpacing());
const double stoppingTime = max(image->w(),image->h());
fastMarching->SetStoppingValue( stoppingTime );
FileWriterType::Pointer writer4 = FileWriterType::New();
writer4->SetFileName("distance.jpg");
writer4->UseCompressionOn();
rescaleFilter->SetOutputMinimum( 0 );
rescaleFilter->SetOutputMaximum( 255 );
rescaleFilter->SetInput( fastMarching->GetOutput() );
floatToUnsignedCharFilter ->SetInput( rescaleFilter->GetOutput() );
writer4->SetInput( floatToUnsignedCharFilter->GetOutput() );
try
{
writer4->Update();
writer4->DebugOn();
}
catch (itk::ExceptionObject &e)
{
std::cerr << e << std::endl;
}
Best,
Siyi Ding
Best,
Sylvia Siyi Ding
> Date: Thu, 1 Oct 2009 13:41:21 -0400
> From: mike.jackson at bluequartz.net
> To: insight-users at itk.org
> Subject: [Insight-users] Threaded Gaussian Filter
>
> Anyone have a threaded version of the Gaussian Filter? I am currently
> using the example code for a Gaussian filter from the ITK distribution
> and for the image size I am throwing at it, the iteration loop takes a
> long time because it performs the filter serially on every pixel.
>
> Thanks
> _________________________________________________________
> Mike Jackson mike.jackson at bluequartz.net
> BlueQuartz Software www.bluequartz.net
> Principal Software Engineer Dayton, Ohio
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
_________________________________________________________________
Lauren found her dream laptop. Find the PC that’s right for you.
http://www.microsoft.com/windows/choosepc/?ocid=ftp_val_wl_290
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091002/98207a9d/attachment.htm>
More information about the Insight-users
mailing list