X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkVectorArithmGenericFilter.txx;h=b4d61279a86602d3ca1337949a89a60b288ba01a;hb=f48c960aef6e0a5a4edea516b062197db009e25f;hp=38c3b873291af48521be746bf45754d467b350c2;hpb=c7562023bd8553e47b394a77ce1d9c17b6feeadc;p=clitk.git diff --git a/tools/clitkVectorArithmGenericFilter.txx b/tools/clitkVectorArithmGenericFilter.txx index 38c3b87..b4d6127 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)) { @@ -115,7 +118,7 @@ void VectorArithmGenericFilter::UpdateWithInputImageType() IteratorType it(input1, input1->GetLargestPossibleRegion()); // typedef input2 - typename ImageType::Pointer input2 = NULL; + typename ImageType::Pointer input2 = ITK_NULLPTR; IteratorType it2; // Special case for normalisation @@ -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()) { @@ -431,7 +436,9 @@ void clitk::VectorArithmGenericFilter::ComputeImage(Iter1 it, It case 12: // normalize while (!it.IsAtEnd()) { PixelType n = it.Get(); - n.Normalize(); + if (n.GetNorm() != 0) + n.Normalize(); + ito.Set(n); ++it; ++ito; @@ -455,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;