Fix vtkImageDifference issues

- Fix a variable intialization issue in vtkImageDifference
- Fix a int/double issue in vtkImageDifference
dev
Mathieu Westphal 2 months ago
parent b8af7f8c77
commit f05c948529

@ -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]

Loading…
Cancel
Save