Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMake/CTestCustom.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
"which will suppress this warning"
"WARNING: Cache entry deserialization failed, entry ignored"
"LabelGeometryImageFilter.*deprecated"
"WARNING: Duplicate C\+\+ declaration"
"note: declared here"
"RemovedInSphinx[0-9]+Warning"
"ipo: warning #11053"
Expand Down
2 changes: 2 additions & 0 deletions src/Filtering/ImageFeature/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ add_example(ApplyAFilterOnlyToASpecifiedImageRegion)

add_example(ApplyAFilterToASpecifiedRegionOfAnImage)

add_example(SimpleContourExtractor)

add_example(ZeroCrossingBasedEdgeDecor)
compare_to_baseline(EXAMPLE_NAME ZeroCrossingBasedEdgeDecor
BASELINE_PREFIX ZeroCrossingBasedEdgeDecor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.22.1)

project(ExtractContoursFromImage)
project(SimpleContourExtractor)

find_package(ITK REQUIRED)
itk_generate_factory_registration()
Expand All @@ -20,11 +20,11 @@ install(TARGETS ${PROJECT_NAME}
)

install(FILES Code.cxx CMakeLists.txt
DESTINATION share/ITKSphinxExamples/Code/Filtering/ImageFeature/ExtractContoursFromImage/
DESTINATION share/ITKSphinxExamples/Code/Filtering/ImageFeature/SimpleContourExtractor/
COMPONENT Code
)


enable_testing()
add_test(NAME ExtractContoursFromImageTest
add_test(NAME SimpleContourExtractorTest
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME})
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,30 @@
* limitations under the License.
*
*=========================================================================*/
/*
Comment thread
dzenanz marked this conversation as resolved.

#include "itkImage.h"
#include "itkImageFileWriter.h"
#include "itkSimpleContourExtractorImageFilter.h"
#include "itkImageRegionIterator.h"

using UnsignedCharImageType = itk::Image<unsigned char, 2>;

static void CreateImage(UnsignedCharImageType::Pointer image);
static void
CreateImage(UnsignedCharImageType::Pointer image);

int main()
int
main()
{
auto image = UnsignedCharImageType::New();
CreateImage(image);

using SimpleContourExtractorImageFilterType = itk::SimpleContourExtractorImageFilter <UnsignedCharImageType, UnsignedCharImageType>;
SimpleContourExtractorImageFilterType::Pointer contourFilter
= SimpleContourExtractorImageFilterType::New();
using SimpleContourExtractorImageFilterType =
itk::SimpleContourExtractorImageFilter<UnsignedCharImageType, UnsignedCharImageType>;
SimpleContourExtractorImageFilterType::Pointer contourFilter = SimpleContourExtractorImageFilterType::New();
contourFilter->SetInput(image);
contourFilter->Update();

using WriterType = itk::ImageFileWriter< UnsignedCharImageType >;
using WriterType = itk::ImageFileWriter<UnsignedCharImageType>;
auto writer = WriterType::New();
writer->SetFileName("output.png");
writer->SetInput(contourFilter->GetOutput());
Expand All @@ -45,36 +47,37 @@ int main()
return EXIT_SUCCESS;
}

void CreateImage(UnsignedCharImageType::Pointer image)
void
CreateImage(UnsignedCharImageType::Pointer image)
{
// Create an image
itk::Index<2> start{};

auto size = itk::Size<2>::Filled(100);

itk::ImageRegion<2> region(start,size);
itk::ImageRegion<2> region(start, size);

image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);

// Create a line pixels
for(unsigned int i = 40; i < 60; ++i)
{
for (unsigned int i = 40; i < 60; ++i)
{
auto pixel = itk::Index<2>::Filled(i);
image->SetPixel(pixel, 255);
}
}

// Create another line of pixels
for(unsigned int i = 10; i < 20; ++i)
{
for (unsigned int i = 10; i < 20; ++i)
{
itk::Index<2> pixel;
pixel[0] = 10;
pixel[1] = i;
image->SetPixel(pixel, 255);
}
}

using WriterType = itk::ImageFileWriter< UnsignedCharImageType >;
using WriterType = itk::ImageFileWriter<UnsignedCharImageType>;
auto writer = WriterType::New();
writer->SetFileName("input.png");
writer->SetInput(image);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:name: ExtractContoursFromImage
:name: SimpleContourExtractor

Extract Contours From Image
===========================
Simple Contour Extractor
========================
.. note::
**Wish List**
Still needs additional work to finish proper creation of example.
Expand Down
2 changes: 1 addition & 1 deletion src/Filtering/ImageFeature/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ ImageFeature
ComputeLaplacian/Documentation.rst
DetectEdgesWithCannyEdgeDetectionFilter/Documentation.rst
DerivativeImage/Documentation.rst
ExtractContoursFromImage/Documentation.rst
FindZeroCrossingsInSignedImage/Documentation.rst
LaplacianRecursiveGaussianImageFilter/Documentation.rst
SegmentBloodVessels/Documentation.rst
SharpenImage/Documentation.rst
SimpleContourExtractor/Documentation.rst
SobelEdgeDetectionImageFilter/Documentation.rst
ZeroCrossingBasedEdgeDecor/Documentation.rst
Loading