[Insight-users] watershed segmentation in own function
Ella Maria Kadas
ella_kadas at yahoo.com
Tue Mar 1 08:06:58 EST 2011
Hi, I had a similar problem and that was in my case because the input i was giving the writer was an empty image. I would suggest that u make an reader->Update(), before u initialize the output image.Cheers,Ella
--- G G <greenlander1986 at gmail.com> schrieb am Di, 1.3.2011:
Von: G G <greenlander1986 at gmail.com>
Betreff: [Insight-users] watershed segmentation in own function
An: "insight-users" <insight-users at itk.org>
Datum: Dienstag, 1. März, 2011 12:17 Uhr
Hi Luis,
I tried to write funcion, which return image after image segmentation. I have this code:
typedef float PixelType;
const unsigned int InputDimension = 3;
typedef itk::Image< PixelType, InputDimension > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( this->settings.getInputPath().c_str() );
const unsigned int OutputDimension = 3;
typedef itk::RGBPixel<unsigned char> RGBPixelType; // ws
typedef itk::Image< RGBPixelType, OutputDimension > OutputImageType; // ws
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( this->settings.getOutputPath().c_str() );
OutputImageType::Pointer output = OutputImageType::New();
output = this->segmentationCC<OutputImageType::Pointer, ImageType, OutputImageType, ImageType::Pointer>(reader->GetOutput());
writer->SetInput(output);
try
{
writer->Update();
//writer->UpdateLargestPossibleRegion();
//writer->UpdateOutputData(output);
}
catch (itk::ExceptionObject &e)
{
this->settings.setLogMessage("Chyba pri zapisu do souboru");
cerr << e << endl;
this->settings.setIsOK(false);
return;
}
then I have to show function segmentationCC:
template<typename TOutputImageTypePointer, typename TImageType, typename TRGBImageType, typename TInput> TOutputImageTypePointer IOCompute::segmentationCC(TInput input)
{
typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< TImageType, TImageType > GradientMagnitudeFilterType;
GradientMagnitudeFilterType::Pointer gradienMagnitudeFilter = GradientMagnitudeFilterType::New();
gradienMagnitudeFilter->SetInput( input );
gradienMagnitudeFilter->SetSigma( 1.0 );
typedef itk::WatershedImageFilter< TImageType > WatershedFilterType;
WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();
watershedFilter->SetInput( gradienMagnitudeFilter->GetOutput() );
watershedFilter->SetThreshold( 0.01 );
watershedFilter->SetLevel( 0.15 );
typedef itk::Functor::ScalarToRGBPixelFunctor< unsigned long > ColorMapFunctorType;
typedef WatershedFilterType::OutputImageType LabeledImageType;
typedef itk::UnaryFunctorImageFilter<
LabeledImageType,
TRGBImageType,
ColorMapFunctorType
> ColorMapFilterType;
ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();
colorMapFilter->SetInput( watershedFilter->GetOutput() );
TOutputImageTypePointer output = colorMapFilter->GetOutput();
return output;
}
when I use writer->Update();
I have exception
itk::ExceptionObject (00A3F388)
Location: "void __thiscall itk::ImageFileWriter<class itk::Image<class itk::RGBPixel<unsigned char>,3> >::Write(void)"
File: c:\itkrel\src\insight\code\io\itkImageFileWriter.txx
Line: 271
Description: itk::ERROR: ImageFileWriter(00B513B8): Largest possible region does not fully contain requested paste IO regionPaste IO region: ImageIORegion (00A3F3F8)
Dimension: 3
Index: 0 0 0
Size: 0 0 0
Largest possible region: ImageRegion (00A3F3DC)
Dimension: 3
Index: [0, 0, 0]
Size: [0, 0, 0]
or when I have writer->UpdateLargestPossibleRegion(); then no exception, but any writter output file :'-(
Please help me or give some advice, I am desperate...
Thanks a lot
-----Integrierter Anhang folgt-----
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110301/2511e2d3/attachment.htm>
More information about the Insight-users
mailing list