Commit 408f8c63 authored by Victor Poughon's avatar Victor Poughon

Merge branch 'dynamic_convert_doc_test' into 'develop'

BUG: Improve Convert and DynamicConvert mask handling (fix #1647)

Closes #1647

See merge request !159
parents 1d81617e e46f2cb5
......@@ -128,8 +128,10 @@ private:
MandatoryOff("type.linear.gamma");
AddParameter(ParameterType_InputImage, "mask", "Input mask");
SetParameterDescription("mask", "The masked pixels won't be used to adapt the dynamic "
"(the mask must have the same dimensions as the input image)");
SetParameterDescription("mask",
"Optional mask to indicate which pixels are valid for computing the histogram quantiles. "
"Only pixels where the mask is less than 0.5 will contribute to the histogram. "
"The mask must have the same dimensions as the input image.");
MandatoryOff("mask");
DisableParameter("mask");
......
......@@ -78,6 +78,8 @@ public:
typedef StreamingShrinkImageFilter<FloatVectorImageType,
FloatVectorImageType> ShrinkFilterType;
typedef StreamingShrinkImageFilter<UInt8ImageType, UInt8ImageType> UInt8ShrinkFilterType;
typedef Functor::LogFunctor<FloatVectorImageType::InternalPixelType> TransferLogFunctor;
typedef UnaryImageFunctorWithVectorImageFilter<FloatVectorImageType,
FloatVectorImageType,
......@@ -90,9 +92,7 @@ private:
SetName("DynamicConvert");
SetDescription("Change the pixel type and rescale the image's dynamic");
// Documentation
SetDocName("Dynamic Conversion");
// TODO
SetDocLongDescription("This application performs an image pixel type "
"conversion (short, ushort, uchar, int, uint, float and double types are "
"handled). The output image is written in the specified format (ie. "
......@@ -135,8 +135,9 @@ private:
AddParameter(ParameterType_InputImage, "mask", "Input mask");
SetParameterDescription("mask",
"The masked pixels won't be used to adapt the dynamic "
"(the mask must have the same dimensions as the input image)");
"Optional mask to indicate which pixels are valid for computing the histogram quantiles. "
"Pixels where the mask is zero will not contribute to the histogram. "
"The mask must have the same dimensions as the input image.");
MandatoryOff("mask");
DisableParameter("mask");
......@@ -300,15 +301,15 @@ private:
// Now we generate the list of samples
if (IsParameterEnabled("mask"))
{
FloatVectorImageType::Pointer mask = this->GetParameterImage("mask");
ShrinkFilterType::Pointer maskShrinkFilter = ShrinkFilterType::New();
UInt8ImageType::Pointer mask = this->GetParameterUInt8Image("mask");
UInt8ShrinkFilterType::Pointer maskShrinkFilter = UInt8ShrinkFilterType::New();
maskShrinkFilter->SetShrinkFactor(shrinkFactor);
maskShrinkFilter->SetInput(mask);
maskShrinkFilter->GetStreamer()->
SetAutomaticAdaptativeStreaming(GetParameterInt("ram"));
maskShrinkFilter->Update();
auto itMask = itk::ImageRegionConstIterator<FloatVectorImageType>(
auto itMask = itk::ImageRegionConstIterator<UInt8ImageType>(
maskShrinkFilter->GetOutput(),
maskShrinkFilter->GetOutput()->GetLargestPossibleRegion());
......@@ -317,8 +318,8 @@ private:
itMask.GoToBegin();
for(; !it.IsAtEnd(); ++it, ++itMask)
{
// float values, so the threshold is set to 0.5
if (itMask.Get()[0] > 0.5)
// valid pixels are non zero
if (itMask.Get() != 0)
{
listSample->PushBack(it.Get());
}
......
......@@ -124,6 +124,20 @@ otb_test_application(NAME apTvUtDynamicConvertFloat
${OTBAPP_BASELINE}/apTvUtDynamicConvertFloatOutput.tif
${TEMP}/apTvUtDynamicConvertFloatOutput.tif)
otb_test_application(NAME apTvUtDynamicConvertMask
APP DynamicConvert
OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
-out ${TEMP}/apTvUtDynamicConvertMaskOutput.tif
-outmin 0
-outmax 255
-quantile.low 4
-quantile.high 4
-mask ${INPUTDATA}/QB_Toulouse_Ortho_PAN_Mask.tif
VALID --compare-image ${NOTOL}
${OTBAPP_BASELINE}/apTvUtDynamicConvertMaskOutput.tif
${TEMP}/apTvUtDynamicConvertMaskOutput.tif)
#----------- PixelInfo TESTS ----------------
#----------- ExtractROI TESTS ----------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment