Skip to content

Commit

Permalink
Use the max value for a uint16. This in reality should work for most …
Browse files Browse the repository at this point in the history
…normal images.

In theory a user could have a data set that uses 64 bit float (or even 32 bit float)
where they might need to bump up the upper boundary value if they data necessitates
that kind of value.

Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Jul 4, 2024
1 parent bfe4742 commit f6906a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ ITKConnectedComponents (ConnectedComponents)

## Description

\par
This method is based on Topological Stable State Thresholding to calculate the threshold set point. This method is particularly effective when there are a large number of objects in a microscopy image. Compiling in Debug mode and enable the debug flag for this filter to print debug information to see how the filter focuses in on a threshold value. Please see the Insight Journal's MICCAI 2005 workshop for a complete description. References are below.

### Parameters

\par Parameters
The MinimumObjectSizeInPixels parameter is controlled through the class Get/SetMinimumObjectSizeInPixels() method. Similar to the standard itk::BinaryThresholdImageFilter the Get/SetInside and Get/SetOutside values of the threshold can be set. The GetNumberOfObjects() and GetThresholdValue() methods return the number of objects above the minimum pixel size and the calculated threshold value.

### Automatic Thresholding in ITK

\par Automatic Thresholding in ITK
There are multiple methods to automatically calculate the threshold intensity value of an image. As of version 4.0, ITK has a Thresholding ( ITKThresholding ) module which contains numerous automatic thresholding methods.implements two of these. Topological Stable State Thresholding works well on images with a large number of objects to be counted.

## References

1) Urish KL, August J, Huard J. "Unsupervised segmentation for myofiber
counting in immunofluorescent microscopy images". Insight Journal. ISC/NA-MIC/MICCAI Workshop on Open-Source Software (2005) https://insight-journal.org/browse/publication/40 2) Pikaz A, Averbuch, A. "Digital image thresholding based on topological
1) Urish KL, August J, Huard J. "Unsupervised segmentation for myofiber counting in immunofluorescent microscopy images". Insight Journal. ISC/NA-MIC/MICCAI Workshop on Open-Source Software (2005) https://insight-journal.org/browse/publication/40
2) Pikaz A, Averbuch, A. "Digital image thresholding based on topological
stable-state". Pattern Recognition, 29(5): 829-843, 1996.

## Questions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using FilterOutputType = uint8;
struct ITKThresholdMaximumConnectedComponentsImageFilterFunctor
{
uint32 minimumObjectSizeInPixels = 0u;
float64 upperBoundary = std::numeric_limits<double>::max();
float64 upperBoundary = 65536.0;
uint8 insideValue = 1u;
uint8 outsideValue = 0u;

Expand All @@ -31,10 +31,7 @@ struct ITKThresholdMaximumConnectedComponentsImageFilterFunctor
using FilterType = itk::ThresholdMaximumConnectedComponentsImageFilter<InputImageT, OutputImageT>;
auto filter = FilterType::New();
filter->SetMinimumObjectSizeInPixels(minimumObjectSizeInPixels);

typename InputImageT::PixelType upperBoundaryPixelValue = static_cast<typename InputImageT::PixelType>(upperBoundary);

filter->SetUpperBoundary(static_cast<typename InputImageT::PixelType>(std::min<typename InputImageT::PixelType>(upperBoundaryPixelValue, itk::NumericTraits<typename InputImageT::PixelType>::max())));
filter->SetUpperBoundary(static_cast<typename InputImageT::PixelType>(std::min<double>(upperBoundary, itk::NumericTraits<typename InputImageT::PixelType>::max())));

Check warning on line 34 in src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Filters/ITKThresholdMaximumConnectedComponentsImageFilter.cpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

implicit conversion from 'itk::NumericTraits<long>::ValueType' (aka 'long') to 'const double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]

Check warning on line 34 in src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Filters/ITKThresholdMaximumConnectedComponentsImageFilter.cpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

implicit conversion from 'itk::NumericTraits<long>::ValueType' (aka 'long') to 'const double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]

Check warning on line 34 in src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Filters/ITKThresholdMaximumConnectedComponentsImageFilter.cpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

implicit conversion from 'itk::NumericTraits<unsigned long>::ValueType' (aka 'unsigned long') to 'const double' changes value from 18446744073709551615 to 18446744073709551616 [-Wimplicit-int-float-conversion]

Check warning on line 34 in src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Filters/ITKThresholdMaximumConnectedComponentsImageFilter.cpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

implicit conversion from 'itk::NumericTraits<unsigned long>::ValueType' (aka 'unsigned long') to 'const double' changes value from 18446744073709551615 to 18446744073709551616 [-Wimplicit-int-float-conversion]
filter->SetInsideValue(insideValue);
filter->SetOutsideValue(outsideValue);
return filter;
Expand Down Expand Up @@ -89,7 +86,7 @@ Parameters ITKThresholdMaximumConnectedComponentsImageFilter::parameters() const
"The following Set/Get methods are for the binary threshold function. This class automatically calculates the lower threshold boundary. The upper threshold boundary, inside value, and outside "
"value can be defined by the user, however the standard values are used as default if not set by the user. The default value of the: Inside value is the maximum pixel type intensity. Outside "
"value is the minimum pixel type intensity. Upper threshold boundary is the maximum pixel type intensity.",
std::numeric_limits<double>::max()));
65536.0));
params.insert(std::make_unique<UInt8Parameter>(
k_InsideValue_Key, "Inside Value",
"The following Set/Get methods are for the binary threshold function. This class automatically calculates the lower threshold boundary. The upper threshold boundary, inside value, and outside "
Expand Down

0 comments on commit f6906a8

Please sign in to comment.