Merge topic 'fix_vtkImageDifference'

036c759d95 Adding a md file
7ca9b8ba4f Adding a vtkImageDifference test
6ba4f52a2a Adding/updating baselines
f05c948529 Fix vtkImageDifference issues

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: Peter Franz <peter.franz@flowstatesolutions.co.nz>
Acked-by: Andreas Buykx <a.buykx@dianafea.com>
Merge-request: !9706
dev
Mathieu Westphal 2 months ago committed by Kitware Robot
commit 08c4b0ad52

@ -0,0 +1,8 @@
# Fixing an impacting issue in vtkImageDifference
A impacting issue in vtkImageDifference has been fixed.
Between vtk 9.1 and 9.2, an change has been made to vtkImageDifference
that causes different image to be identified as not different
depending on how the vtkImageDifference was configured.
This fix may causes some testing to start failing.

@ -1 +1 @@
343a9b2eed50587bb42996fdbfabe9940b554aeee3a000671db8a82335cbb5cbdda9e38df2abb8b539c618369444c2e8d3678faa7d00c984f93a852937ea6300
566e29348edcaf6ba1d1104f8d88204d9b6c81829ad9cff8f8db6d828e20ac6e897e4a15e9b7aa8e78a97f14baa2aab26d43634c88a890f83a357eddb4f9c3ff

@ -0,0 +1 @@
7711e1e97b476ca5943081699ef45805f27b34cca17aa6de33be100545654b67121d84b0898f85ed33ceb52f7a39708b5b2d2889b9d82ceffc8a5ba5c22ebd72

@ -0,0 +1 @@
f63d1e9f84655024083b28bd6eaa238f0600dace14ed37e513cfda77d94e3c3ac7053b1d7d1866379aeda58720e766f526fe1c716c942d653c0081192f18d03a

@ -0,0 +1 @@
7e4147ea4cf7012363d201fa56915682871d463be4cdc1c90f57c9204912aefbebba487d54b880ac6b24d099073fb6121fe32d8408a9cf74a05cc00887c658e9

@ -0,0 +1 @@
8ac5471e02b9d1088a9ce3d9701deb3c5a4e1bb2116d8516b7c342766805ba49f0de1ebb4ea38abb692c4a08409556de2f0718257f1e305d08a1ba69dbf2fa2a

@ -0,0 +1 @@
95e6a2895fa6a21c9ccd04fdfdd29bb9d6bf521aa1d779a4353c8a721472c42b16e6f2f77aa59b146b1afe0e8e37abc8e9317dadae4d60e2bcd1a32d65536cca

@ -0,0 +1 @@
72bc116bb7552e4a75a31f74beeffb4830f571448fbefe8c3992264a94386d01f5173951274c4183a78db2eca92152e77a242d1aad21fb34634dc32a1c82dbc9

@ -0,0 +1 @@
2c453bcb8a6097e8e4ae83de559c474e9bb1ed52e9c5b88a300d7dd80b8e8d45014e05bb02bc11d9061f265e9dc4ae0d9266dfb66b954c49b4bf319b5f780c30

@ -0,0 +1 @@
d52a40d50ab5aa49bcbcf70e611863c1e15b38a8c1695b4d7e35cd5ee6d33eb9b94b9bd4f092b291660042e269a58cec5c5504afc1746557c8a5704b4afd674a

@ -0,0 +1 @@
6f3f09f86a76c15d0f98193a5c6468e06fe44a24ca100c5b10c28ac225e33552984c4ead62507092015aed59c6a4157f48f6594958a019737fc7d90602d18c47

@ -1 +1 @@
343a9b2eed50587bb42996fdbfabe9940b554aeee3a000671db8a82335cbb5cbdda9e38df2abb8b539c618369444c2e8d3678faa7d00c984f93a852937ea6300
566e29348edcaf6ba1d1104f8d88204d9b6c81829ad9cff8f8db6d828e20ac6e897e4a15e9b7aa8e78a97f14baa2aab26d43634c88a890f83a357eddb4f9c3ff

@ -0,0 +1 @@
69659798efebd49b13e550792f76f848e0866d5d68f4bde590f599ddd0d5a342bc5cf2ee2a52149b72947094d83e1e983a891c9b0721805c0bffda789fea7945

@ -0,0 +1 @@
177b3044b9890d99ca8de1f9157441fef2a69c9cf5bb99bc4d73320ce7476dcbf9838cb3ae90357713f6eb5951002174456085bc74bb27191e3497c27bf57cc7

@ -0,0 +1 @@
efdaf260bb793de1f23ccc964a8bbcf9aae54cade4dd14776915d6b240924a5a937b8b51a50f0941df653399d23654d684c3327a80ddc61e4f82dc38623371c3

@ -1,4 +1,6 @@
vtk_module_test_data(
Data/ImageDiff1.png
Data/ImageDiff2.png
Data/beach.tif
Data/fullhead15.png
Data/headsq/,REGEX:.*)

@ -4,6 +4,7 @@ vtk_add_test_cxx(vtkImagingCoreCxxTests tests
ImageAccumulateLarge.cxx,NO_VALID,NO_DATA,NO_OUTPUT 32
ImageAutoRange.cxx
ImageBSplineCoefficients.cxx
ImageDifference.cxx,NO_VALID
ImageGenericInterpolateSlidingWindow3D.cxx
ImageHistogram.cxx
ImageHistogramStatistics.cxx,NO_VALID

@ -0,0 +1,142 @@
/*=========================================================================
Program: Visualization Toolkit
Module: ImageDifference.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// Test the vtkImageDifference class
#include "vtkImageDifference.h"
#include "vtkMathUtilities.h"
#include "vtkNew.h"
#include "vtkPNGReader.h"
#include "vtkTestUtilities.h"
#include <iostream>
#include <limits>
namespace
{
bool CheckErrors(vtkImageDifference* differenceFilter, double expectedError,
double expectedThresholdedError, const std::string& info)
{
if (!vtkMathUtilities::FuzzyCompare(differenceFilter->GetError(), expectedError, 1e-8) ||
!vtkMathUtilities::FuzzyCompare(
differenceFilter->GetThresholdedError(), expectedThresholdedError, 1e-8))
{
std::cerr << std::setprecision(std::numeric_limits<double>::digits10);
std::cerr << std::setprecision(17);
std::cerr << "Unexpected vtkImageDifference errors with " << info << std::endl;
std::cerr << "Expected error: " << expectedError << ", got: " << differenceFilter->GetError()
<< " " << (expectedError != differenceFilter->GetError()) << std::endl;
std::cerr << "Expected thresholded error: " << expectedThresholdedError
<< ", got: " << differenceFilter->GetThresholdedError() << " "
<< (expectedThresholdedError != differenceFilter->GetThresholdedError()) << std::endl;
return false;
}
return true;
}
}
int ImageDifference(int argc, char* argv[])
{
char* fname1 = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/ImageDiff1.png");
char* fname2 = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/ImageDiff2.png");
vtkNew<vtkPNGReader> reader1;
reader1->SetFileName(fname1);
reader1->Update();
vtkNew<vtkPNGReader> reader2;
reader2->SetFileName(fname2);
reader2->Update();
delete[] fname1;
delete[] fname2;
vtkNew<vtkImageDifference> differenceFilter;
differenceFilter->SetInputConnection(reader1->GetOutputPort());
differenceFilter->SetImageConnection(reader2->GetOutputPort());
// Default param
differenceFilter->Update();
if (!::CheckErrors(
differenceFilter, 10600.898039215839, 0.97124183006535825, "default parameters"))
{
return EXIT_FAILURE;
}
// Testing symmetric
differenceFilter->SetInputConnection(reader2->GetOutputPort());
differenceFilter->SetImageConnection(reader1->GetOutputPort());
differenceFilter->Update();
if (!::CheckErrors(
differenceFilter, 10600.898039215839, 0.97124183006535825, "symmetric testing"))
{
return EXIT_FAILURE;
}
// Zero threshold
differenceFilter->SetThreshold(0);
differenceFilter->Update();
if (!::CheckErrors(differenceFilter, 9342.9607843138092, 9342.9607843138092, "zero threshold"))
{
return EXIT_FAILURE;
}
// Higher average threshold
differenceFilter->SetThreshold(105);
differenceFilter->SetAverageThresholdFactor(1.);
differenceFilter->Update();
if (!::CheckErrors(
differenceFilter, 10594.431372549172, 0.22614379084967323, "higher average threshold"))
{
return EXIT_FAILURE;
}
// No averaging
differenceFilter->SetAverageThresholdFactor(0.5);
differenceFilter->SetAveraging(false);
differenceFilter->Update();
if (!::CheckErrors(differenceFilter, 10600.898039215839, 0.97124183006535825, "no averaging"))
{
return EXIT_FAILURE;
}
// No shift
differenceFilter->SetAveraging(true);
differenceFilter->SetAllowShift(false);
differenceFilter->Update();
if (!::CheckErrors(differenceFilter, 9587.1254901961565, 1.1986928104575143, "no shift"))
{
return EXIT_FAILURE;
}
// Multi param
differenceFilter->SetThreshold(0);
differenceFilter->SetAveraging(false);
differenceFilter->Update();
if (!::CheckErrors(
differenceFilter, 9587.1254901961565, 9587.1254901961565, "multiple parameters changes"))
{
return EXIT_FAILURE;
}
// Identical
differenceFilter->SetInputConnection(reader1->GetOutputPort());
differenceFilter->Update();
if (!::CheckErrors(differenceFilter, 0., 0., "identical images"))
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

@ -26,6 +26,7 @@
VTK_ABI_NAMESPACE_BEGIN
constexpr int MAX_NCOMPS = 4;
constexpr double DEFAULT_ERROR = 1000.;
using max_ncomps_array_t = std::array<int, MAX_NCOMPS>;
vtkStandardNewMacro(vtkImageDifference);
@ -318,7 +319,6 @@ void vtkImageDifference::ThreadedRequestData(vtkInformation* vtkNotUsed(request)
max_ncomps_array_t rgbaMax;
rgbaMax.fill(0);
max_ncomps_array_t rgbaTresh;
rgbaTresh.fill(1000);
// ignore the boundary within two pixels as we cannot
// do a good average calc on the boundary
@ -327,6 +327,7 @@ void vtkImageDifference::ThreadedRequestData(vtkInformation* vtkNotUsed(request)
{
for (int direction = 0; direction <= 1; ++direction)
{
rgbaTresh.fill(DEFAULT_ERROR);
unsigned char* dir1Ptr0 = direction == 0 ? in1Ptr0 : in2Ptr0;
unsigned char* dir2Ptr0 = direction == 0 ? in2Ptr0 : in1Ptr0;
bool haveValues = false;
@ -402,7 +403,7 @@ void vtkImageDifference::ThreadedRequestData(vtkInformation* vtkNotUsed(request)
std::copy(rgbaMax.begin(), rgbaMax.end(), rgbaTresh.begin());
error += std::accumulate(rgbaTresh.begin(), rgbaTresh.end(), 0) / (nComp * 255);
error += std::accumulate(rgbaTresh.begin(), rgbaTresh.end(), 0.) / (nComp * 255.);
for (int i = 0; i < nComp; i++)
{
@ -411,7 +412,7 @@ void vtkImageDifference::ThreadedRequestData(vtkInformation* vtkNotUsed(request)
*outPtr0++ = static_cast<unsigned char>(rgbaTresh[i]);
}
thresholdedError +=
std::accumulate(rgbaTresh.begin(), rgbaTresh.end(), 0) / (nComp * 255.0);
std::accumulate(rgbaTresh.begin(), rgbaTresh.end(), 0.) / (nComp * 255.);
in1Ptr0 += nComp;
in2Ptr0 += nComp;
@ -490,8 +491,8 @@ int vtkImageDifference::RequestData(
// Report errors here, do not report errors while multithreading!
vtkErrorMacro("RequestData: " << this->ErrorMessage);
this->ErrorMessage = nullptr;
this->Error = 1000.0;
this->ThresholdedError = 1000.0;
this->Error = DEFAULT_ERROR;
this->ThresholdedError = DEFAULT_ERROR;
ret = 0;
}
@ -516,8 +517,8 @@ int vtkImageDifference::RequestInformation(vtkInformation* vtkNotUsed(request),
if (in1Ext[0] != in2Ext[0] || in1Ext[1] != in2Ext[1] || in1Ext[2] != in2Ext[2] ||
in1Ext[3] != in2Ext[3] || in1Ext[4] != in2Ext[4] || in1Ext[5] != in2Ext[5])
{
this->Error = 1000.0;
this->ThresholdedError = 1000.0;
this->Error = DEFAULT_ERROR;
this->ThresholdedError = DEFAULT_ERROR;
vtkErrorMacro("ExecuteInformation: Input are not the same size.\n"
<< " Input1 is: " << in1Ext[0] << "," << in1Ext[1] << "," << in1Ext[2] << "," << in1Ext[3]

@ -1 +1 @@
a8460972b36bdae53eb0e3e21becf7c0f3d8fb187bd3d0827cafc6d28f07b0ef59b08a7715ecc4eae7bfee697a3b6ee0591b0ff255de2f225489f5a4cfe26b7d
552ede7d4431905b3b21f8cedd4605007b3b6d557b4f50463dfe369a9e16338921d4625b6f481f953e5f1e5e8fdf8b84124c297031bea8b0a01ccf4dce4343ae

@ -1 +1 @@
33e1713c9fcc79ccfa318cbb7cb49b49047205b4e41ac9a28995bc6a19426e9b506eb2251da2d779b7df1a1772999454add1ba1662ef31ca0c6a45aca53f706a
ddf29581f745e29ec6fa1de44f4e88dad467fcfd33298f3dfa4365ab9d5d50c258dafde7048a21e2e14ca969f8961d44812b2242b4ae77856975438004e272c0

@ -0,0 +1 @@
27e3642ffc80140307c747f3ac326d6043ccbb5fc069562302bea73edd67b1c784c7b2920e3a12ef08f64caf36006563eb2d2f7f41acf1afd0c8239f3ad25124

@ -0,0 +1 @@
6f14a3f8233cf495e8ee9f6cb73f5a65005205c9bc990a220b3ca796e5ef415dfc5ccb8a8aa89163c852db916c2acd62953b9655d9f51a87b32329cf483ea46a

@ -0,0 +1 @@
e9fa27dd527d98cdb8d8a915cbc67c0eb2e80200cda57498932a874e410d517c92d79ab3a110d4d51712ee8af6157b59f1052a0a755a72ac3ea9fef2224052c8

@ -1 +1 @@
c00399d5d0475dd85d6a65f51e5a3ccbb506c2976470750947900f69581a4ba4a73bcd6533d5823731eda5e67d64d606871762e548efe6824cdb2dd05cdfd128
18eeb74ffc34aa56acbb93270759b9fa3330c337bd590fe7719412706c0bf12ddfafe075f9b9b8dada33956a91d80cc6b2309dccfb8baf4195c3bd239846759e

@ -1 +1 @@
9015c94269f3c4d7e3a9479b770088e517c6f6806edb9d661235ebd1e88ad4e314a8aac2e46cd86519be3a34cfeb4a71bd15c11565b369060f511bc1084200ca
bf21dc2f47d4e467c1867853026955d70149f1b5efe918ad4e818ae01be00dcd3fc3191842a76707d1875c1cda52f0854191230883661d4cb69806f7065d9dcc

@ -0,0 +1 @@
d433e15a7e9bfb3b03eb5b5c73d3956782fd1f5662008ceb5180600202c87e4c47e541c4409c1bca5a6083183f3a005aeb70155c218a9977478ae9900d773963

@ -0,0 +1 @@
2f6bf435136d567d6f9a4199f657073002f39d6c83dafac64223f6f6bb8d3af13cfe8c43f2e781695caff1f13019e02f58007f4d042c85c0eee3211f38758ce8
Loading…
Cancel
Save