Skip to content

Commit

Permalink
ENH: Remove zeroes if not considering negative values
Browse files Browse the repository at this point in the history
If negative attenuations should not be considered,
then do not set the mask for those pixels.
Instead leave them at negative values, but keep the mask off.

Update regression test baseline images.
  • Loading branch information
dzenanz committed Apr 11, 2022
1 parent b8a8ecc commit 71d1368
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
17 changes: 7 additions & 10 deletions include/itkAttenuationImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,13 @@ AttenuationImageFilter<TInputImage, TOutputImage, TMaskImage>::ThreadedGenerateD
output->SetPixel(start, output->GetPixel(start) / accumulatedWeight[start[m_Direction]]);
accumulatedWeight[start[m_Direction]] = 0.0f; // reset for next next inclusion segment

// Possibly eliminate negative attenuations
if (!m_ConsiderNegativeAttenuations && output->GetPixel(start) < 0.0)
// Only set mask for valid estimates
if (m_ConsiderNegativeAttenuations || output->GetPixel(start) >= 0.0)
{
output->SetPixel(start, 0.0);
// Dynamically generate the output mask with values corresponding to input
m_OutputMaskImage->SetPixel(start, inputMaskImage->GetPixel(start));
}

// Dynamically generate the output mask with values corresponding to input
m_OutputMaskImage->SetPixel(start, inputMaskImage->GetPixel(start));

++start[m_Direction];
} // while start<=end
}
Expand All @@ -272,12 +270,11 @@ AttenuationImageFilter<TInputImage, TOutputImage, TMaskImage>::ThreadedGenerateD
// Compute mid-point index
target[m_Direction] = (start[m_Direction] + target[m_Direction]) / 2;
output->SetPixel(target, estimatedAttenuation);
m_OutputMaskImage->SetPixel(target, inputMaskImage->GetPixel(target));

// Possibly eliminate negative attenuations
if (!m_ConsiderNegativeAttenuations && estimatedAttenuation < 0.0)
// Only set mask for valid estimates
if (m_ConsiderNegativeAttenuations || estimatedAttenuation >= 0.0)
{
output->SetPixel(target, 0.0);
m_OutputMaskImage->SetPixel(target, inputMaskImage->GetPixel(target));
}
}
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e68b8c8468ea0bf3e8679de20aafdde9b4b9809e0f8ae22a10ca9cd76c11ce2919f36be1bfded16c72f65da85ed41b5f346c48f451d1e4987977e4979bcc1686
ccec81929272444c5b6ba79bf76220443a964686c0d270f81db02800b2c667ea746d16ce43c941d2fd18db0a9f72735f34f746e0d8a8fbefbfca0aac5a2db66c
Original file line number Diff line number Diff line change
@@ -1 +1 @@
56302d9bb3adc00f11db875b3c70c188e53f778362a42597589d963c0b1658df0e39ab2706e8d86d062977b7dcc70cc3437064c3b975757d95bd9f1a21cb0518
aec37bd428b4076859d6d23d04a3bbd5ab7e399fe0b88d3e4a079a59f5878234d6f5384749d9da1dc8a7b9ab5fcbde8887037bdd13535342442cc38f88dfdec8
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e68b8c8468ea0bf3e8679de20aafdde9b4b9809e0f8ae22a10ca9cd76c11ce2919f36be1bfded16c72f65da85ed41b5f346c48f451d1e4987977e4979bcc1686
ccec81929272444c5b6ba79bf76220443a964686c0d270f81db02800b2c667ea746d16ce43c941d2fd18db0a9f72735f34f746e0d8a8fbefbfca0aac5a2db66c
6 changes: 3 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ itk_add_test(NAME itkAttenuationImageFilterTest
0.0 # Distance between pixels sampled for attenuation estimation; 0.0 -> inclusion length
0 # consider negative attenuations
0 # computation mode
0.173493 # median attenuation
0.273958 # median attenuation
)
itk_add_test(NAME itkAttenuationImageFilterMultithreadedTest
COMMAND UltrasoundTestDriver
Expand All @@ -89,7 +89,7 @@ itk_add_test(NAME itkAttenuationImageFilterMultithreadedTest
0.0 # Distance between pixels sampled for attenuation estimation; 0.0 -> inclusion length
0 # consider negative attenuations
0 # computation mode
0.173493 # median attenuation
0.273958 # median attenuation
)
itk_add_test(NAME itkAttenuationImageFilterFixedEstimationDistanceTest
COMMAND UltrasoundTestDriver
Expand All @@ -108,7 +108,7 @@ itk_add_test(NAME itkAttenuationImageFilterFixedEstimationDistanceTest
3.0 # Distance between pixels sampled for attenuation estimation
0 # consider negative attenuations
0 # computation mode
0.173493 # median attenuation
0.273958 # median attenuation
)
itk_add_test(NAME itkAttenuationImageFilterFixedDistanceModeTest
COMMAND UltrasoundTestDriver
Expand Down

0 comments on commit 71d1368

Please sign in to comment.