|
|
(2 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| The path only seems to have 1 pixel (where it should have ~30)?
| | {{warning|1=The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.}} |
| | |
| ==FloodFilledImageFunctionConditionalIterator.cxx== | |
| <source lang="cpp">
| |
| #include "itkImage.h"
| |
| #include "itkImageFileWriter.h"
| |
| #include "itkFloodFilledImageFunctionConditionalIterator.h"
| |
| #include "itkBinaryThresholdImageFunction.h"
| |
| #include "itkImageFileWriter.h"
| |
| | |
| typedef itk::Image< unsigned char, 2 > ImageType;
| |
| | |
| static void CreateImage(ImageType::Pointer image);
| |
| | |
| int main( int argc, char *argv[])
| |
| {
| |
| ImageType::Pointer image = ImageType::New();
| |
| CreateImage(image);
| |
| | |
| typedef itk::BinaryThresholdImageFunction< ImageType, double > FunctionType;
| |
| FunctionType::Pointer function = FunctionType::New();
| |
| function->SetInputImage(image);
| |
| function->ThresholdAbove(100); // we are looking to capture 255
| |
| | |
| typedef itk::FloodFilledImageFunctionConditionalIterator< ImageType, FunctionType > IteratorType;
| |
| | |
| itk::Index<2> seed;
| |
| seed[0] = 25;
| |
| seed[1] = 25;
| |
| | |
| std::vector<itk::Index<2> > seeds;
| |
| seeds.push_back(seed);
| |
| | |
| IteratorType it (image, function, seeds);
| |
| it.GoToBegin();
| |
| | |
| while ( !it.IsAtEnd() )
| |
| {
| |
| std::cout << it.GetIndex() << std::endl;
| |
| ++it;
| |
| }
| |
| | |
| return EXIT_SUCCESS;
| |
| }
| |
| | |
| void CreateImage(ImageType::Pointer image)
| |
| {
| |
| itk::Index<2> start;
| |
| start.Fill(0);
| |
| | |
| itk::Size<2> size;
| |
| size.Fill(100);
| |
| | |
| itk::ImageRegion<2> region(start,size); | |
| image->SetRegions(region);
| |
| image->Allocate();
| |
| image->FillBuffer(0);
| |
| | |
| // Make a line
| |
| for(unsigned int i = 20; i < 50; ++i)
| |
| {
| |
| itk::Index<2> pixelIndex;
| |
| pixelIndex.Fill(i);
| |
| | |
| image->SetPixel(pixelIndex, 255);
| |
| }
| |
| | |
| }
| |
| | |
| </source>
| |
| | |
| {{ITKCMakeLists|FloodFilledImageFunctionConditionalIterator}}
| |