Skip to content
Permalink
Browse files

BUG: Enable use of labelValue for output label map

A bug was introduced in svn 22211 [1] when the labelValue parameter in the ModelToLabelMap CLI was exposed to the interface.
The erosion and dilation filters used in the code are binary ones and by default use the maximum of the data type of the label
map, in this case hard coded to 255 for unsigned char. In order to do the full pipeline with the user selected label value, the
code would need to be updated to use:
erodeFilter->SetErodeValue(labelValue);
dilateFilter->SetDilateValue(labelValue);
A quicker fix is to adjust the output label map in the last step to set the desired label value, implemented in this patch.

Investigating this issue, the hard coded kernel size was set into a variable, in anticipation of exposing it via the XML
(quick tests showed no visible difference).

Added a test and output using the label value 128. When run from the GUI, the model and volume were offset, so a transformed model
was generated that overlaps the input volume and was used to generate the new baseline comparison volume.
Removed unused baseline image.

[1] http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=22211

Issue #3233

git-svn-id: http://svn.slicer.org/Slicer4/trunk@25062 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information...
naucoin committed May 13, 2016
1 parent 5e5ec48 commit 8707bb9ed2503f67ac0af29782c16db97adeab40
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

@@ -190,12 +190,13 @@ int DoIt( int argc, char * argv[])

if( label->GetLargestPossibleRegion().IsInside(idx) )
{
label->SetPixel( idx, labelValue );
label->SetPixel( idx, 255 );
}
}

// do morphological closing
LabelImageType::Pointer closedLabel = BinaryClosingFilter3D( label, 2);
unsigned int kernelRadius = 2;
LabelImageType::Pointer closedLabel = BinaryClosingFilter3D( label, kernelRadius );
itk::ImageRegionIteratorWithIndex<LabelImageType> itLabel(closedLabel, closedLabel->GetLargestPossibleRegion() );

// do flood fill using binary threshold image function
@@ -229,13 +230,20 @@ int DoIt( int argc, char * argv[])
for( floodFill.GoToBegin(); !floodFill.IsAtEnd(); ++floodFill )
{
LabelImageType::IndexType i = floodFill.GetIndex();
closedLabel->SetPixel( i, labelValue );
closedLabel->SetPixel( i, 255 );
}
LabelImageType::Pointer finalLabel = BinaryClosingFilter3D( closedLabel, 2);
LabelImageType::Pointer finalLabel = BinaryClosingFilter3D( closedLabel, kernelRadius );
for( itLabel.GoToBegin(); !itLabel.IsAtEnd(); ++itLabel )
{
LabelImageType::IndexType i = itLabel.GetIndex();
label->SetPixel( i, finalLabel->GetPixel(i) );
if (finalLabel->GetPixel(i) == 255)
{
label->SetPixel( i, labelValue );
}
else
{
label->SetPixel( i, finalLabel->GetPixel(i) );
}
}

typename WriterType::Pointer writer = WriterType::New();
@@ -21,3 +21,17 @@ add_test(NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $<TARGET_FILE:${CLP}Test
${TEMP}/${CLP}TestOutput.mha
)
set_property(TEST ${testname} PROPERTY LABELS ${CLP})

# With a different output label
set(testname ${CLP}TestLabelValue)
add_test(NAME ${testname} COMMAND ${SEM_LAUNCH_COMMAND} $<TARGET_FILE:${CLP}Test>
--compare ${BASELINE}/OAS10001-128.mha
${TEMP}/${CLP}TestLabelValueOutput.mha
--compareNumberOfPixelsTolerance 20
ModuleEntryPoint
--labelValue 128
${INPUT}/OAS10001.hdr
${INPUT}/OAS10001-Transformed.vtp
${TEMP}/${CLP}TestLabelValueOutput.mha
)
set_property(TEST ${testname} PROPERTY LABELS ${CLP})

0 comments on commit 8707bb9

Please sign in to comment.
You can’t perform that action at this time.