From 9ddf481ab9e8ad4371d71d831579165b64bbdc58 Mon Sep 17 00:00:00 2001 From: tbaudier Date: Mon, 12 Jun 2017 15:04:35 +0200 Subject: [PATCH] Separate term to term multiplication and dotproduct with VectorArithm --- tools/clitkVectorArithm.ggo | 2 +- tools/clitkVectorArithmGenericFilter.txx | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/clitkVectorArithm.ggo b/tools/clitkVectorArithm.ggo index 5c7d65e..3e21fca 100644 --- a/tools/clitkVectorArithm.ggo +++ b/tools/clitkVectorArithm.ggo @@ -13,7 +13,7 @@ option "input2" j "Input second image filename" string no option "output" o "Output image filename" string yes option "scalar" s "Scalar value" double no -option "operation" t "Type of operation : \n With another image : 0=add, 1=multiply (dotproduct), 7=difference, 9=crossproduct\n; For 'scalar' : 0=add, 1=multiply, 5=absval (magnitude), 6=squared magnitude, 11=divide, 12=normalize" int default="0" no +option "operation" t "Type of operation : \n With another image : 0=add, 1=multiply, 2=dotproduct, 7=difference, 9=crossproduct\n; For 'scalar' : 0=add, 1=multiply, 5=absval (magnitude), 6=squared magnitude, 11=divide, 12=normalize" int default="0" no option "pixelValue" - "Default value for NaN/Inf" double default="0.0" no option "setFloatOutput" f "Set output to float pixel type" flag off diff --git a/tools/clitkVectorArithmGenericFilter.txx b/tools/clitkVectorArithmGenericFilter.txx index 1f4cb72..50e36dd 100644 --- a/tools/clitkVectorArithmGenericFilter.txx +++ b/tools/clitkVectorArithmGenericFilter.txx @@ -79,13 +79,16 @@ void VectorArithmGenericFilter::SetArgsInfo(const args_info_type if (mArgsInfo.input2_given) { mIsOperationUseASecondImage = true; this->AddInputFilename(mArgsInfo.input2_arg); - if (mArgsInfo.operation_arg == 1) + if (mArgsInfo.operation_arg == 2) mIsOutputScalar = true; } else if (mArgsInfo.operation_arg == 5 || mArgsInfo.operation_arg == 6) mIsOutputScalar = true; - if (mArgsInfo.output_given) this->SetOutputFilename(mArgsInfo.output_arg); + if (mArgsInfo.output_given) { + this->SetOutputFilename(mArgsInfo.output_arg); + mOverwriteInputImage = false; + } // Check type of operation (with scalar or with other image) if ((mArgsInfo.input2_given) && (mArgsInfo.scalar_given)) { @@ -217,16 +220,18 @@ void VectorArithmGenericFilter::ComputeImage(Iter1 it1, Iter2 i ++ito; } break; - /* - case 1: // Multiply + + case 1: // term to term Multiply while (!ito.IsAtEnd()) { - ito.Set(it1.Get() * it2.Get()) ); + typename Iter1::PixelType outputPixel(ito.Get()); + outputPixel.SetVnlVector(element_product(it1.Get().GetVnlVector(),it2.Get().GetVnlVector())); + ito.Set(outputPixel); ++it1; ++it2; ++ito; } break; - */ + /* case 2: // Divide while (!ito.IsAtEnd()) { @@ -457,7 +462,7 @@ void VectorArithmGenericFilter::ComputeScalarImage(Iter1 it1, I typedef typename Iter3::PixelType PixelType; switch (mTypeOfOperation) { - case 1: // Multiply + case 2: // Multiply while (!ito.IsAtEnd()) { ito.Set(it1.Get() * it2.Get()); ++it1; -- 2.45.1