Discussion:
Floodfill segmentation or is there an other possibillity in itk
Oliver Trebbe
2008-03-25 13:27:07 UTC
Permalink
Hello Guys,

i have a problem, i want to segment 3d images in a special way, using
floodfilling with integrated neighborhood checking, but i don´t get an
idea using the iterator´s for this problem, maybe someone can help me
getting my mind ready or can give me some tips or ideas using the
iterators right...
the problem is i want to use the x y z dimensions but cant read them
anywhere...
and just iterating through the voxels isnt the right way...
can i use pointers to the previous iterator? or next (or so)
how to define or use them?
would be thankfull if someone can help me

Thanks

Oliver
Luis Ibanez
2008-03-25 14:22:58 UTC
Permalink
Hi Oliver,


You probably should use the FloodFilledImageFunctionConditionalIterator.


Please read the code of the itkConnectedThresholdImageFilter.txx file
in the directory Insight/Code/BasicFilters.


You should pay particular attention to lines 255-275:


typedef BinaryThresholdImageFunction<
InputImageType, double> FunctionType;

typedef FloodFilledImageFunctionConditionalIterator<
OutputImageType, FunctionType> IteratorType;

typename FunctionType::Pointer function = FunctionType::New();
function->SetInputImage ( inputImage );
function->ThresholdBetween ( m_Lower, m_Upper );

ProgressReporter progress(this, 0, region.GetNumberOfPixels());

IteratorType it ( outputImage, function, m_SeedList );
it.GoToBegin();

while( !it.IsAtEnd())
{
it.Set(m_ReplaceValue);
++it;
progress.CompletedPixel(); // potential exception thrown here
}




You can implement your variation of flood-filling by defining a new
ImageFunction to replace the BinaryThresholdImageFunction. Your new
image function will define the criteria that allows to accept a new
pixel into the region.



Regards,



Luis



---------------------------
Post by Oliver Trebbe
Hello Guys,
i have a problem, i want to segment 3d images in a special way, using
floodfilling with integrated neighborhood checking, but i don´t get an
idea using the iterator´s for this problem, maybe someone can help me
getting my mind ready or can give me some tips or ideas using the
iterators right...
the problem is i want to use the x y z dimensions but cant read them
anywhere...
and just iterating through the voxels isnt the right way...
can i use pointers to the previous iterator? or next (or so)
how to define or use them?
would be thankfull if someone can help me
Thanks
Oliver
_______________________________________________
Insight-users mailing list
http://www.itk.org/mailman/listinfo/insight-users
Oliver Trebbe
2008-03-26 13:02:00 UTC
Permalink
Hi Luis,

that sounds good, but how may i first floodfill my volume till i find
one pixel(which discribes a region starting point) which is what i want
to find, go to the max intensity( this is already prototyped ) in that
region, and from there do a floodfill which checks intensities within a
neighborhood and 'disables' this 'region' for another floodfill...
go further with the max intensity check till the terminating condition
is hit... after that, disable the region where the max intensity checks
were driven and go on finding the next region....

what about this function?
how to write my own?
cant i just use the floodfilling without specifiing a function...
(maybe i just need to learn more about this templated generic
programming ;))

is there anything in itk which does such things, or, do i need to try to
write an own filter...
are there other mathematical operations or so to do that?
maybe i´m too new to pattern recognition or how to call this discipline ;)

Thanks
Oliver
Post by Luis Ibanez
Hi Oliver,
You probably should use the FloodFilledImageFunctionConditionalIterator.
Please read the code of the itkConnectedThresholdImageFilter.txx file
in the directory Insight/Code/BasicFilters.
typedef BinaryThresholdImageFunction<
InputImageType, double> FunctionType;
typedef FloodFilledImageFunctionConditionalIterator<
OutputImageType, FunctionType> IteratorType;
typename FunctionType::Pointer function = FunctionType::New();
function->SetInputImage ( inputImage );
function->ThresholdBetween ( m_Lower, m_Upper );
ProgressReporter progress(this, 0, region.GetNumberOfPixels());
IteratorType it ( outputImage, function, m_SeedList );
it.GoToBegin();
while( !it.IsAtEnd())
{
it.Set(m_ReplaceValue);
++it;
progress.CompletedPixel(); // potential exception thrown here
}
You can implement your variation of flood-filling by defining a new
ImageFunction to replace the BinaryThresholdImageFunction. Your new
image function will define the criteria that allows to accept a new
pixel into the region.
Regards,
Luis
---------------------------
Post by Oliver Trebbe
Hello Guys,
i have a problem, i want to segment 3d images in a special way, using
floodfilling with integrated neighborhood checking, but i don´t get
an idea using the iterator´s for this problem, maybe someone can help
me getting my mind ready or can give me some tips or ideas using the
iterators right...
the problem is i want to use the x y z dimensions but cant read them
anywhere...
and just iterating through the voxels isnt the right way...
can i use pointers to the previous iterator? or next (or so)
how to define or use them?
would be thankfull if someone can help me
Thanks
Oliver
_______________________________________________
Insight-users mailing list
http://www.itk.org/mailman/listinfo/insight-users
Luis Ibanez
2008-03-28 15:07:57 UTC
Permalink
Hi Oliver,

This is a bit more complicated than the original question :-)

Several of the ITK filters actually perform multiple passes of
Floodfill. That is no problem. You simply run multiple loops
of the Floodfill iterator inside the GenerateData() method of
your new filter.

See for example:

itkConfidenceConnectedImageFilter
itkIsolatedConnectedImageFilter


Both of them perform multiple floodfill passes.

In your case, however, you may need different criteria for
including pixels on each pass. That is, for the first pass
you use one criterion, while for the second pass you use
another one.

That being said....

The description of your algorithm has some resemblance to
watershed, and I'm wondering if you may benefit from reading
the following papers from the Insight Journal:


"The watershed transform in ITK - discussion and new developments"
http://hdl.handle.net/1926/202

and

"Finding regional extrema - methods and performance"
http://hdl.handle.net/1926/153


In order to get familiar with the use of floodfiling
I would advice you to look first at the code of the filter


itkConnectedThresholdImageFilter


This is the simplest instance of a filter using flood filling.
Once you feel confident with this filter, move on and read the
code of the itkConficenceConnectedImageFilter.


Of course, once you get your filter done, we will strongly
encourage you to share it with the ITK community by posting
it to the Insight Journal.


Please let us know if you have any other questions,


Thanks


Luis



--------------------
Post by Oliver Trebbe
Hi Luis,
that sounds good, but how may i first floodfill my volume till i find
one pixel(which discribes a region starting point) which is what i want
to find, go to the max intensity( this is already prototyped ) in that
region, and from there do a floodfill which checks intensities within a
neighborhood and 'disables' this 'region' for another floodfill...
go further with the max intensity check till the terminating condition
is hit... after that, disable the region where the max intensity checks
were driven and go on finding the next region....
what about this function?
how to write my own?
cant i just use the floodfilling without specifiing a function...
(maybe i just need to learn more about this templated generic
programming ;))
is there anything in itk which does such things, or, do i need to try to
write an own filter...
are there other mathematical operations or so to do that?
maybe i´m too new to pattern recognition or how to call this discipline ;)
Thanks
Oliver
Post by Luis Ibanez
Hi Oliver,
You probably should use the FloodFilledImageFunctionConditionalIterator.
Please read the code of the itkConnectedThresholdImageFilter.txx file
in the directory Insight/Code/BasicFilters.
typedef BinaryThresholdImageFunction<
InputImageType, double> FunctionType;
typedef FloodFilledImageFunctionConditionalIterator<
OutputImageType, FunctionType> IteratorType;
typename FunctionType::Pointer function = FunctionType::New();
function->SetInputImage ( inputImage );
function->ThresholdBetween ( m_Lower, m_Upper );
ProgressReporter progress(this, 0, region.GetNumberOfPixels());
IteratorType it ( outputImage, function, m_SeedList );
it.GoToBegin();
while( !it.IsAtEnd())
{
it.Set(m_ReplaceValue);
++it;
progress.CompletedPixel(); // potential exception thrown here
}
You can implement your variation of flood-filling by defining a new
ImageFunction to replace the BinaryThresholdImageFunction. Your new
image function will define the criteria that allows to accept a new
pixel into the region.
Regards,
Luis
---------------------------
Post by Oliver Trebbe
Hello Guys,
i have a problem, i want to segment 3d images in a special way, using
floodfilling with integrated neighborhood checking, but i don´t get
an idea using the iterator´s for this problem, maybe someone can help
me getting my mind ready or can give me some tips or ideas using the
iterators right...
the problem is i want to use the x y z dimensions but cant read them
anywhere...
and just iterating through the voxels isnt the right way...
can i use pointers to the previous iterator? or next (or so)
how to define or use them?
would be thankfull if someone can help me
Thanks
Oliver
_______________________________________________
Insight-users mailing list
http://www.itk.org/mailman/listinfo/insight-users
Loading...