Change 22134 - Needs Code-Review
WIP: Improve Thresholding module filters' coverage. Improve the ITKThresholding module filters' coverage: - Exercise basic object methods. Remove redundant calls to print the filter. - Exercise the Set/Get methods using the TEST_SET_GET_VALUE and On/Off methods using the TEST_SET_GET_BOOLEAN macro. - Use the TRY_EXPECT_NO_EXCEPTION macro for all filter update calls to save typing try/catch blocks. - Use TRY_EXPECT_EXCEPTION to try/catch expected exceptions when possible/appropriate. - Refactor the tests to accept (more) input parameters to check the classes under a broader range of conditions. In many cases, the parameters accepted belong to inherited propertis (e.g. itk::HistogramThresholdImageFilter: m_NumberOfHistogramBins, m_AutoMinimumMaximum, m_MaskOutput, m_MaskValue). Keep the default values of the class for existing tests. - Make the tests quantitative: compare the compute threshold to the expected one. - Add the hash code to compare to the baseline for new tests. - Remove unnecessary print messages. - Style changes: define the image dimension as a constant; use a typedef for the pixel type; use a variable to set the output's inside/outside value so that its Set/Get methods can be clearly tested; try to use the same sequence of sentences across all tests; change '\n' to std::endl. - Improve the messages in the threshold regression tests to make the consistent across the tests/the entire toolkit, and to provide rich information. - Finished the tests with a "Test finished" message; helps telling in the the dashboard whether the failure has happened in the test or the comparison to the baseline. - In itkBinaryThresholdImageFilterTest.cxx, set the functor before updating the filter. - Correct the arguments passed to SetSigmaFactor and SetNumberOfIterations in itkKappaSigmaThresholdImageFilterTest.cxx (the expected sigmaFactor as defined by the order in the CMakeLists command/usage explanation was being set to the number of iterations of the filter and vice-versa). Update the corresponding baselines accordingly. Change-Id: I9d6050d9e474b17fe3639faa7a5b16c052440e21
Author Feb 13, 2017 1:23 PM
Committer Apr 21, 2017 11:10 AM
Commit
197a55a11b4ebf810b6e66c475d735f115362897
Parent(s)
ca0c11ccad9aa0c5c3211674e328c4ff52f54b38
Change-Id
I9d6050d9e474b17fe3639faa7a5b16c052440e21
Owner
Uploader
Reviewers
Kitware Build Robot
Alvaro Sanchez Bradley Lowekamp Dirk Padfield Francois Budin Gaëtan Lehmann Karthik Krishnan Matt McCormick Richard Beare kent williams
Project ITK
Branch master
Topic
Strategy Always Merge
Cannot Merge
Updated 1 year, 8 months ago

Build-Status
Code-Review
Verified
-1 Kitware Build Robot
 
 
Files
File PathCommentsSize
Commit Message
Modules/Filtering/Thresholding/test/Baseline/itkKappaSigmaThresholdImageFilterTest01.png.md52
DModules/Filtering/Thresholding/test/Baseline/itkKappaSigmaThresholdImageFilterTest01.png.sha5121
Modules/Filtering/Thresholding/test/Baseline/itkKappaSigmaThresholdImageFilterTest02.png.md52
DModules/Filtering/Thresholding/test/Baseline/itkKappaSigmaThresholdImageFilterTest02.png.sha5121
Modules/Filtering/Thresholding/test/Baseline/itkOtsuThresholdImageFilterTest.png.md52
DModules/Filtering/Thresholding/test/Baseline/itkOtsuThresholdImageFilterTest.png.sha5121
AModules/Filtering/Thresholding/test/Baseline/itkOtsuThresholdImageFilterTestFlipInsideOut.png.md51
Modules/Filtering/Thresholding/test/CMakeLists.txt163
Modules/Filtering/Thresholding/test/itkBinaryThresholdImageFilterTest.cxx277
Modules/Filtering/Thresholding/test/itkBinaryThresholdImageFilterTest2.cxx69
Modules/Filtering/Thresholding/test/itkBinaryThresholdProjectionImageFilterTest.cxx87
Modules/Filtering/Thresholding/test/itkBinaryThresholdSpatialFunctionTest.cxx90
Modules/Filtering/Thresholding/test/itkHuangMaskedThresholdImageFilterTest.cxx115
Modules/Filtering/Thresholding/test/itkHuangThresholdImageFilterTest.cxx116
Modules/Filtering/Thresholding/test/itkIntermodesMaskedThresholdImageFilterTest.cxx130
Modules/Filtering/Thresholding/test/itkIntermodesThresholdImageFilterTest.cxx129
Modules/Filtering/Thresholding/test/itkIsoDataMaskedThresholdImageFilterTest.cxx112
Modules/Filtering/Thresholding/test/itkIsoDataThresholdImageFilterTest.cxx114
Modules/Filtering/Thresholding/test/itkKappaSigmaThresholdImageCalculatorTest.cxx96
Modules/Filtering/Thresholding/test/itkKappaSigmaThresholdImageFilterTest.cxx121
Modules/Filtering/Thresholding/test/itkKittlerIllingworthMaskedThresholdImageFilterTest.cxx113
Modules/Filtering/Thresholding/test/itkKittlerIllingworthThresholdImageFilterTest.cxx114
Modules/Filtering/Thresholding/test/itkLiMaskedThresholdImageFilterTest.cxx113
Modules/Filtering/Thresholding/test/itkLiThresholdImageFilterTest.cxx114
Modules/Filtering/Thresholding/test/itkMaximumEntropyMaskedThresholdImageFilterTest.cxx102
Modules/Filtering/Thresholding/test/itkMaximumEntropyThresholdImageFilterTest.cxx114
Modules/Filtering/Thresholding/test/itkMomentsMaskedThresholdImageFilterTest.cxx115
Modules/Filtering/Thresholding/test/itkMomentsThresholdImageFilterTest.cxx114
Modules/Filtering/Thresholding/test/itkOtsuMaskedThresholdImageFilterTest.cxx111
Modules/Filtering/Thresholding/test/itkOtsuMultipleThresholdsCalculatorTest.cxx114
Modules/Filtering/Thresholding/test/itkOtsuMultipleThresholdsImageFilterTest.cxx130
Modules/Filtering/Thresholding/test/itkOtsuThresholdCalculatorTest.cxx152
Modules/Filtering/Thresholding/test/itkOtsuThresholdCalculatorVersusOtsuMultipleThresholdsCalculatorTest.cxx61
Modules/Filtering/Thresholding/test/itkOtsuThresholdImageFilterTest.cxx118
Modules/Filtering/Thresholding/test/itkRenyiEntropyMaskedThresholdImageFilterTest.cxx115
Modules/Filtering/Thresholding/test/itkRenyiEntropyThresholdImageFilterTest.cxx114
Modules/Filtering/Thresholding/test/itkShanbhagMaskedThresholdImageFilterTest.cxx114
Modules/Filtering/Thresholding/test/itkShanbhagThresholdImageFilterTest.cxx115
Modules/Filtering/Thresholding/test/itkThresholdLabelerImageFilterTest.cxx2
Modules/Filtering/Thresholding/test/itkTriangleMaskedThresholdImageFilterTest.cxx114
Modules/Filtering/Thresholding/test/itkTriangleThresholdImageFilterTest.cxx114
Modules/Filtering/Thresholding/test/itkYenMaskedThresholdImageFilterTest.cxx115
Modules/Filtering/Thresholding/test/itkYenThresholdImageFilterTest.cxx114
+2691, -1440
History
Jon Hait... Gorroño
Mar 7, 2017

Uploaded patch set 1.

Jon Hait... Gorroño
Mar 7, 2017

Patch Set 1:

A few specific comments:

  • Many of the lines not covered are exceptions or special conditions that seem hard to be met without a deeper insight. So unfortunately even if the topic gets merged, some files will have many lines that are not exercised. If anybody happens to have some suggestions on this, I would be happy to add further test code to address the remaining lines in another topic.
  • I still need to upload the new baselines generated. Namely, those that correspond to the tests having the AutoMinMax flag to false. However, I realize that for the filters that I've tested this condition either breaks the test or produces a black image.

For example, the itkMomentsThredholsImagefilterTestNoAutoMinMax breaks at 60% of the progress because the itkMomentsThresholdCalculator.hxx:94 calls the GetMeasurement with the threshold being -1 (int), while the definition at itk::Histogram::GetMeasurement expects it to be of type InstanceIdentifier, which turns to be unsigned long in this case. Hence, the type casting results in a out of range vector exception. Am I missing something? Is this a bug?

For the cases where I get a black I image, I fear that the result is not correct. Hence, I'm wondering if the flag should ever be set to false. If yes, which parameter am I missing to get meaningful results?

  • I still need to correct the MD5 hash comparison in CMakeLists.txt for the new baselines generated.
  • There are many tests that break during execution. An example is
  • The
  • itkBinaryThresholdSpatialFunctionTest.cxx
  • does not test any class in the Thresholding module, but:

\Core\Common\include\itkBinaryThresholdSpatialFunction.h \Segmentation\SignedDistanceFunction\include\itkSphereSignedDistanceFunction.h \Core\Common\include\itkFloodFilledSpatialFunctionConditionalConstIterator.h Should the test be moved elsewhere? Or else, should the filter itself be moved to the Thresholding folder?

  • I did not use the number of histograms or autominmax parameters in the masked versions. Let me know if it would be highly desirable to test them as well.
  • For the itkIntermodesThresholdImageFilterTest.cxx, I'd dare to say that the calculator maximum number of iterations is not being effectively set/used. When debugging the test, it becomes apparent that the exception is caught not due to an arbitrary value of 200 that I set, but due to the default value of 10000 being exceeded. Looks like the cause is that instead of using the filter's m_IntermodesCalculator, it's the Superclass' m_Calculator instance that is used when performing the computations. Thus, it does not seem fair to me that the property has no effect on the filter. Is this a bug? Am I missing something?
Kitware Build Robot
Mar 7, 2017
Richard Beare
Mar 7, 2017

Patch Set 1:

Looks like there is a lot to look at here. I won't be able to help much for a couple of weeks. Looks like a good start, but we need to sort out those questions you've raised

Jon Hait... Gorroño
Mar 7, 2017

Patch Set 1:

Thanks Richard.

I'll try to fix the errors having to do with the tests having an incorrect number of parameters.

As for the concerns I raised, I'll wait for your thoughts.

Jon Hait... Gorroño
Mar 9, 2017

Patch Set 1:

Also, a short note: all error messages are sent to std::cout, instead of std::cerr. I realized that std::cerr may not be set in the build sites when I found that it was not set locally for my git bash. Hence, at times relevant error messages are not printed and may lead to confusion when debugging.

It has happened a few times to me with the remote sites.

If you think we should redirect error messages to std::cerr, let me know so that I change it for the files in this topic.

Jon Hait... Gorroño
Mar 9, 2017

Uploaded patch set 2.

Kitware Build Robot
Mar 9, 2017
Jon Hait... Gorroño
Mar 10, 2017

Uploaded patch set 3.

Kitware Build Robot
Mar 10, 2017
Jon Hait... Gorroño
Mar 11, 2017

Uploaded patch set 4.

Kitware Build Robot
Mar 11, 2017
Jon Hait... Gorroño
Mar 11, 2017

Patch Set 4:

Now it's good to go to fix the AutoMinMax issues. Apart from the need to fix the expected value for the threshold regression tests, I still get black images in such cases.

Jon Hait... Gorroño
Mar 14, 2017

Uploaded patch set 5: Patch Set 4 was rebased.

Kitware Build Robot
Mar 14, 2017
Jon Hait... Gorroño
Mar 21, 2017

Uploaded patch set 6.

Kitware Build Robot
Mar 21, 2017
Jon Hait... Gorroño
Apr 21, 2017

Uploaded patch set 7.

Jon Hait... Gorroño
Apr 21, 2017

Patch Set 7:

Patch set 7 fixes the breaking (producing SEGFAULTS) tests.

Talking to Richard to try to fix the black image output issues.

Will likely update the thread soon.

Kitware Build Robot
Apr 21, 2017
Richard Beare
Apr 23, 2017

Patch Set 7:

Hi Everyone, Thanks for the efforts so far. Here's what I think is going on with the AutoMinimumMaximum settings.

When setting up a histogram it is necessary to specify a range of values that are going to be put into it so that the bins can be created. When the "auto" flag is off in the max and min settings appear to be derived from the max and min of the pixel type: ImageToHistogramFilter, lines 209 and 217. This makes sense if the image dynamic range is a substantial proportion of the pixel type.

If the pixel range is used (auto=off) for, say, unsigned short types, while the input dynamic range is actually unsigned char, then we end up with all the data in a tiny number of bins, not providing a useful approximation of the distribution, and probably leading to crazy threshold estimates (like all black).

I think that if the auto flag is off for larger pixel types we should have some way of explicitly setting the min/max used by the histogram generator, but it looks as though this is missing. It would be useful to be able to set the range explicitly if the data had some outliers and some robust estimation of range was necessary, or the range was already known and we want to optimize things by avoiding recalculation.

Thus, I think our problem here is that we don't have a way of setting the range when we turn auto calculation off. There is no reason to expect sensible results if the auto flag is off and no alternative estimate of range is provided.

The default is to have auto on for non char pixel types.

Powered by Gerrit Static Archive (2.12-1-g6f7dc21) |