From: David Sarrut Date: Wed, 13 Feb 2013 15:47:52 +0000 (+0100) Subject: Merge branch 'master' of git.creatis.insa-lyon.fr:clitk X-Git-Tag: v1.4.0~246 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ca952d6acc32974f1e84d60f2bced4eb31d575fc;hp=d5b914b5db163964744fe83b7e3556e834f50ada;p=clitk.git Merge branch 'master' of git.creatis.insa-lyon.fr:clitk --- diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 8f9ce0f..8cd82fb 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -235,6 +235,11 @@ namespace clitk { template void MapToVecSecond(const M & m, V & v); + //-------------------------------------------------------------------- + // Find/replace string + template + int inline findAndReplace(T& source, const T& find, const T& replace); + #include "clitkCommon.txx" } // end namespace diff --git a/common/clitkCommon.txx b/common/clitkCommon.txx index 5ee83bd..845e62f 100644 --- a/common/clitkCommon.txx +++ b/common/clitkCommon.txx @@ -235,5 +235,22 @@ void MapToVecSecond(const M & m, V & v) { } //-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +//http://stackoverflow.com/questions/1494399/how-do-i-search-find-and-replace-in-a-standard-string +template +int inline findAndReplace(T& source, const T& find, const T& replace) +{ + int num=0; + int fLen = find.size(); + int rLen = replace.size(); + for (int pos=0; (pos=source.find(find, pos))!=T::npos; pos+=rLen) { + num++; + source.replace(pos, fLen, replace); + } + return num; +} +//-------------------------------------------------------------------- + #endif /* end #define CLITKCOMMON_TXX */ diff --git a/common/clitkFilterBase.cxx b/common/clitkFilterBase.cxx index 32dd9b4..f6bebad 100644 --- a/common/clitkFilterBase.cxx +++ b/common/clitkFilterBase.cxx @@ -49,7 +49,7 @@ void clitk::FilterBase::SetWarning(std::string e) //-------------------------------------------------------------------- -void clitk::FilterBase::StartNewStep(std::string s) +void clitk::FilterBase::StartNewStep(std::string s, bool endl) { if (Cancelled()) { throw clitk::ExceptionObject("Filter is canceled."); @@ -69,7 +69,8 @@ void clitk::FilterBase::StartNewStep(std::string s) m_CurrentStepName = "Step "+GetCurrentStepId()+" -- "+s; if (GetVerboseStepFlag()) { - std::cout << m_CurrentStepName << std::endl; + std::cout << m_CurrentStepName; + if (endl) std::cout << std::endl; //"Step " << GetCurrentStepId() << " -- " << s << std::endl; } } diff --git a/common/clitkFilterBase.h b/common/clitkFilterBase.h index b05f64d..7403f37 100644 --- a/common/clitkFilterBase.h +++ b/common/clitkFilterBase.h @@ -118,7 +118,7 @@ namespace clitk { protected: FilterBase(); virtual ~FilterBase() {} - void StartNewStep(std::string s); + void StartNewStep(std::string s, bool endl=true); template void StopCurrentStep(typename TInternalImageType::Pointer p, std::string txt=""); void StopCurrentStep(); diff --git a/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h b/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h index 9946554..781775f 100644 --- a/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h +++ b/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h @@ -143,6 +143,9 @@ namespace clitk { itkGetConstMacro(Radius, double); itkSetMacro(Radius, double); + itkSetMacro(K1, double); + itkGetMacro(K1, double); + typename FloatImageType::Pointer GetFuzzyMap() { return m_FuzzyMap; } // I dont want to verify inputs information @@ -171,6 +174,7 @@ namespace clitk { bool m_FuzzyMapOnlyFlag; bool m_FastFlag; double m_Radius; + double m_K1; virtual void GenerateOutputInformation(); virtual void GenerateInputRequestedRegion(); diff --git a/itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx b/itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx index ddcad0e..a3759f4 100644 --- a/itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx +++ b/itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx @@ -65,6 +65,7 @@ AddRelativePositionConstraintToLabelImageFilter(): FuzzyMapOnlyFlagOff(); FastFlagOff(); SetRadius(2.0); + SetK1(vcl_acos(-1.0)/2); } //-------------------------------------------------------------------- @@ -387,12 +388,9 @@ GenerateData() relPosFilter->SetInput(working_image); relPosFilter->SetAlpha1(m_Angle1[i]); // xy plane relPosFilter->SetAlpha2(m_Angle2[i]); - relPosFilter->SetK1(M_PI/2.0); // Opening parameter, default = pi/2 - - // relPosFilter->SetFast(true); - // relPosFilter->SetRadius(1); // seems sufficient in this case - + relPosFilter->SetK1(GetK1());// M_PI/2.0); // Opening parameter, default = pi/2 // relPosFilter->SetVerboseProgress(true); + relPosFilter->Update(); relPos = relPosFilter->GetOutput(); @@ -444,6 +442,7 @@ GenerateData() resampleFilter->SetGaussianFilteringEnabled(false); resampleFilter->Update(); relPos = m_FuzzyMap = resampleFilter->GetOutput(); + StopCurrentStep(relPos); // Need to put exactly the same size if (relPos->GetLargestPossibleRegion() != input->GetLargestPossibleRegion()) { diff --git a/itk/clitkExtractSliceFilter.txx b/itk/clitkExtractSliceFilter.txx index 43874d0..a449388 100644 --- a/itk/clitkExtractSliceFilter.txx +++ b/itk/clitkExtractSliceFilter.txx @@ -106,6 +106,7 @@ GenerateData() { m_region.SetSize(m_size); int start = m_index[GetDirection()]; this->SetNumberOfOutputs(m_NumberOfSlices); + // deprecated : use SetNumberOfIndexedInputs ? FIXME //-------------------------------------------------------------------- // loop ExtractImageFilter with region updated, push_back @@ -122,7 +123,7 @@ GenerateData() { extract->SetDirectionCollapseToSubmatrix(); #endif extract->Update(); - SetNthOutput(i, extract->GetOutput()); + this->SetNthOutput(i, extract->GetOutput()); } return; } diff --git a/itk/clitkLabelImageOverlapMeasureFilter.txx b/itk/clitkLabelImageOverlapMeasureFilter.txx index a29aa6a..0375709 100644 --- a/itk/clitkLabelImageOverlapMeasureFilter.txx +++ b/itk/clitkLabelImageOverlapMeasureFilter.txx @@ -94,9 +94,17 @@ GenerateData() ImagePointer image_intersection = clitk::Clone(input1); clitk::Or(image_union, input2, GetBackgroundValue()); clitk::And(image_intersection, input2, GetBackgroundValue()); + + ImagePointer image_1NotIn2 = clitk::Clone(input1); + clitk::AndNot(image_1NotIn2, input2, GetBackgroundValue()); + ImagePointer image_2NotIn1 = clitk::Clone(input2); + clitk::AndNot(image_2NotIn1, input1, GetBackgroundValue()); + //writeImage(image_union, "union.mha"); //writeImage(image_intersection, "intersection.mha"); + //writeImage(image_1NotIn2, "image_1NotIn2.mha"); + //writeImage(image_2NotIn1, "image_2NotIn1.mha"); // Compute size typedef itk::LabelStatisticsImageFilter StatFilterType; @@ -121,12 +129,24 @@ GenerateData() statFilter->Update(); int in2 = statFilter->GetCount(GetLabel1()); + statFilter->SetInput(image_1NotIn2); + statFilter->SetLabelInput(image_1NotIn2); + statFilter->Update(); + int l1notIn2 = statFilter->GetCount(GetLabel1()); + + statFilter->SetInput(image_2NotIn1); + statFilter->SetLabelInput(image_2NotIn1); + statFilter->Update(); + int l2notIn1 = statFilter->GetCount(GetLabel1()); + double dice = 2.0*(double)inter/(double)(in1+in2); int width = 6; std::cout << std::setw(width) << in1 << " " << std::setw(width) << in2 << " " << std::setw(width) << inter << " " << std::setw(width) << u << " " + << std::setw(width) << l1notIn2 << " " + << std::setw(width) << l2notIn1 << " " << std::setw(width) << dice << " "; //std::endl; } //-------------------------------------------------------------------- diff --git a/itk/clitkSegmentationUtils.h b/itk/clitkSegmentationUtils.h index 6389ad1..a63fd28 100644 --- a/itk/clitkSegmentationUtils.h +++ b/itk/clitkSegmentationUtils.h @@ -85,11 +85,13 @@ namespace clitk { template typename ImageType::Pointer AutoCrop(const ImageType * input, - typename ImageType::PixelType BG) { + typename ImageType::PixelType BG, + const bool useBorderFlag=false) { typedef clitk::AutoCropFilter AutoCropFilterType; typename AutoCropFilterType::Pointer autoCropFilter = AutoCropFilterType::New(); autoCropFilter->SetInput(input); autoCropFilter->SetBackgroundValue(BG); + autoCropFilter->SetUseBorder(useBorderFlag); autoCropFilter->Update(); return autoCropFilter->GetOutput(); } diff --git a/itk/clitkSegmentationUtils.txx b/itk/clitkSegmentationUtils.txx index a57d813..de243ad 100644 --- a/itk/clitkSegmentationUtils.txx +++ b/itk/clitkSegmentationUtils.txx @@ -354,7 +354,7 @@ namespace clitk { ++iter; } if (!found) return false; - input->TransformIndexToPhysicalPoint(max, point); + input->TransformIndexToPhysicalPoint(max, point); // half of the pixel return true; } //-------------------------------------------------------------------- @@ -382,14 +382,12 @@ namespace clitk { int dim, double max, bool autoCrop, typename ImageType::PixelType BG) { - typename ImageType::PointType p; + typename ImageType::PointType p; + image->TransformIndexToPhysicalPoint(image->GetLargestPossibleRegion().GetIndex()+ image->GetLargestPossibleRegion().GetSize(), p); - // Add GetSpacing because remove Lower or equal than - // DD(max); - // DD(p); - // DD(max+image->GetSpacing()[dim]); - return CropImageAlongOneAxis(image, dim, max+image->GetSpacing()[dim], p[dim], autoCrop, BG); + + return CropImageAlongOneAxis(image, dim, max, p[dim], autoCrop, BG); } //-------------------------------------------------------------------- @@ -404,16 +402,24 @@ namespace clitk { // Compute region size typename ImageType::RegionType region; typename ImageType::SizeType size = image->GetLargestPossibleRegion().GetSize(); - typename ImageType::PointType p = image->GetOrigin(); + + // Starting index + typename ImageType::PointType p = image->GetOrigin(); // not at pixel center ! if (min > p[dim]) p[dim] = min; // Check if not outside the image typename ImageType::IndexType start; image->TransformPhysicalPointToIndex(p, start); - double m = image->GetOrigin()[dim] + size[dim]*image->GetSpacing()[dim]; + + // Size of the region + // -1 because last point is size -1 + double m = image->GetOrigin()[dim] + (size[dim]-1)*image->GetSpacing()[dim]; if (max > m) p[dim] = m; // Check if not outside the image else p[dim] = max; + typename ImageType::IndexType end; image->TransformPhysicalPointToIndex(p, end); - size[dim] = abs(end[dim]-start[dim]); + size[dim] = abs(end[dim]-start[dim])+1;// +1 because we want to include the point. + + // Set region region.SetIndex(start); region.SetSize(size); diff --git a/itk/clitkSliceBySliceRelativePositionFilter.h b/itk/clitkSliceBySliceRelativePositionFilter.h index ba59467..5989e20 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.h +++ b/itk/clitkSliceBySliceRelativePositionFilter.h @@ -138,4 +138,8 @@ namespace clitk { #include "clitkSliceBySliceRelativePositionFilter.txx" #endif +typedef unsigned char PixelType_uchar; +typedef itk::Image ImageType_uchar; +extern template class clitk::SliceBySliceRelativePositionFilter; + #endif diff --git a/itk/clitkSliceBySliceRelativePositionFilter.txx b/itk/clitkSliceBySliceRelativePositionFilter.txx index e68514d..16571ea 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.txx +++ b/itk/clitkSliceBySliceRelativePositionFilter.txx @@ -43,6 +43,7 @@ SliceBySliceRelativePositionFilter(): SetObjectCCLSelectionDirection(1); ObjectCCLSelectionIgnoreSingleCCLFlagOff(); VerboseSlicesFlagOff(); + this->SetK1(vcl_acos(-1.0)/2); } //-------------------------------------------------------------------- @@ -98,7 +99,8 @@ PrintOptions(std::ostream & os) << "ObjectCCLSelectionIgnoreSingleCCLFlag = " << this->GetObjectCCLSelectionIgnoreSingleCCLFlag() << std::endl << "IgnoreEmptySliceObjectFlag = " << this->GetIgnoreEmptySliceObjectFlag() << std::endl << "(RP) FastFlag = " << this->GetFastFlag() << std::endl - << "(RP) Radius = " << this->GetRadius() << std::endl; + << "(RP) Radius = " << this->GetRadius() << std::endl + << "(RP) K1 = " << this->GetK1() << std::endl; } //-------------------------------------------------------------------- @@ -238,6 +240,10 @@ GenerateOutputInformation() int nb=0; mObjectSlices[i] = LabelizeAndCountNumberOfObjects(mObjectSlices[i], 0, true, 1, nb); + if (GetVerboseSlicesFlag()) { + std::cout << "slice " << i << " nb = " << nb << std::endl; + } + // If no object and empty slices and if we need the full fuzzy map, create a dummy one. if ((nb==0) && (this->GetFuzzyMapOnlyFlag())) { typename FloatSliceType::Pointer one = FloatSliceType::New(); @@ -295,6 +301,7 @@ GenerateOutputInformation() if (GetVerboseSlicesFlag()) { std::cout << "Slice " << i << std::endl; relPosFilter->VerboseStepFlagOn(); + //relPosFilter->WriteStepFlagOn(); } relPosFilter->WriteStepFlagOff(); // relPosFilter->VerboseMemoryFlagOn(); @@ -319,6 +326,7 @@ GenerateOutputInformation() // relPosFilter->SetComputeFuzzyMapFlag(this->GetComputeFuzzyMapFlag()); relPosFilter->SetFastFlag(this->GetFastFlag()); relPosFilter->SetRadius(this->GetRadius()); + relPosFilter->SetK1(this->GetK1()); // Go ! relPosFilter->Update(); diff --git a/segmentation/CMakeLists.txt b/segmentation/CMakeLists.txt index 2e1ddac..c9dc114 100644 --- a/segmentation/CMakeLists.txt +++ b/segmentation/CMakeLists.txt @@ -8,6 +8,7 @@ ENDFOREACH(clitkTool) ADD_LIBRARY(clitkSegmentationGgoLib clitkFilterWithAnatomicalFeatureDatabaseManagement.cxx clitkAnatomicalFeatureDatabase.cxx + clitkSliceBySliceRelativePositionFilter_uchar.cxx ${GGO_C_FILES}) #========================================================= diff --git a/segmentation/clitkConnectedComponentLabelingGenericFilter.txx b/segmentation/clitkConnectedComponentLabelingGenericFilter.txx index 1a5ab24..cb38852 100644 --- a/segmentation/clitkConnectedComponentLabelingGenericFilter.txx +++ b/segmentation/clitkConnectedComponentLabelingGenericFilter.txx @@ -46,6 +46,7 @@ void clitk::ConnectedComponentLabelingGenericFilter::InitializeIma { ADD_IMAGE_TYPE(Dim, uchar); ADD_IMAGE_TYPE(Dim, short); + ADD_IMAGE_TYPE(Dim, ushort); // ADD_IMAGE_TYPE(Dim, int); ADD_IMAGE_TYPE(Dim, float); } diff --git a/segmentation/clitkRelativePositionList.txx b/segmentation/clitkRelativePositionList.txx index 4f4702b..d1c41b0 100644 --- a/segmentation/clitkRelativePositionList.txx +++ b/segmentation/clitkRelativePositionList.txx @@ -173,19 +173,22 @@ GenerateOutputInformation() { for(uint i=0; i(sname, "_S", " "); + std::string text = "["+sname+"] "; if (mArgsInfoList[i].orientation_given) text += std::string(mArgsInfoList[i].orientation_arg[0])+" "; else text = text+"("+toString(mArgsInfoList[i].angle1_arg)+" "+ toString(mArgsInfoList[i].angle2_arg)+" "+ (mArgsInfoList[i].inverse_flag?"true":"false")+") "; text = text+mArgsInfoList[i].object_arg+" "+toString(mArgsInfoList[i].threshold_arg); if (mArgsInfoList[i].sliceBySlice_flag) { - text += " slice by slice"; + text += " SbS"; } else text += " 3D"; - text += " spacing=" + toString(mArgsInfoList[i].spacing_arg); + text += " sp=" + toString(mArgsInfoList[i].spacing_arg)+" "; - StartNewStep(text); + StartNewStep(text, false); // no endl typename RelPosFilterType::Pointer relPosFilter; // Is it slice by slice or 3D ? @@ -198,6 +201,7 @@ GenerateOutputInformation() { f->SetUniqueConnectedComponentBySliceFlag(mArgsInfoList[i].uniqueCCL_flag); f->SetObjectCCLSelectionFlag(mArgsInfoList[i].uniqueObjectCCL_flag); f->IgnoreEmptySliceObjectFlagOn(); + f->SetVerboseSlicesFlag(mArgsInfoList[i].verboseSlices_flag); //f->SetObjectCCLSelectionDimension(0); //f->SetObjectCCLSelectionDirection(-1); //f->SetAutoCropFlag(false); @@ -227,7 +231,7 @@ GenerateOutputInformation() { filter->SetInput(1, m_reference); filter->Update(); } - + std::cout << std::endl; } } //-------------------------------------------------------------------- @@ -260,6 +264,7 @@ SetFilterOptions(typename RelPosFilterType::Pointer filter, ArgsInfoType & optio ImagePointer object = GetAFDB()->template GetImage(options.object_arg); filter->SetInputObject(object); filter->WriteStepFlagOff(); + if (options.writeStep_flag) filter->WriteStepFlagOn(); filter->SetVerboseImageSizeFlag(GetVerboseImageSizeFlag()); filter->SetFuzzyThreshold(options.threshold_arg); filter->SetInverseOrientationFlag(options.inverse_flag); // MUST BE BEFORE AddOrientationTypeString diff --git a/segmentation/clitkSliceBySliceRelativePositionFilter_uchar.cxx b/segmentation/clitkSliceBySliceRelativePositionFilter_uchar.cxx new file mode 100644 index 0000000..f0138af --- /dev/null +++ b/segmentation/clitkSliceBySliceRelativePositionFilter_uchar.cxx @@ -0,0 +1,29 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + ======================================================================-====*/ + +#ifndef CLITKSLICEBYSLICERELATIVEPOSITIONFILTER_UCHARH +#define CLITKSLICEBYSLICERELATIVEPOSITIONFILTER_UCHARH + +// clitk +#include "clitkSliceBySliceRelativePositionFilter.h" + +typedef unsigned char PixelType_uchar; +typedef itk::Image ImageType_uchar; +template class clitk::SliceBySliceRelativePositionFilter; + +#endif diff --git a/tools/clitkAffineTransformGenericFilter.txx b/tools/clitkAffineTransformGenericFilter.txx index 93cd16c..0fa4869 100644 --- a/tools/clitkAffineTransformGenericFilter.txx +++ b/tools/clitkAffineTransformGenericFilter.txx @@ -211,6 +211,12 @@ AffineTransformGenericFilter::UpdateWithDimAndPixelType() typename itk::Matrix invRotMatrix( clitk::GetRotationalPartMatrix(invMatrix) ); typename itk::Vector invTrans = clitk::GetTranslationPartMatrix(invMatrix); + // Display warning + if (m_ArgsInfo.spacing_given) + std::cout << "Warning --spacing ignored (because --transform_grid_flag)" << std::endl; + if (m_ArgsInfo.origin_given) + std::cout << "Warning --origin ignored (because --transform_grid_flag)" << std::endl; + // Spacing is influenced by affine transform matrix and input direction typename InputImageType::SpacingType outputSpacing; outputSpacing = invRotMatrix * diff --git a/tools/clitkAutoCropGenericFilter.txx b/tools/clitkAutoCropGenericFilter.txx index 933ce40..e20ec58 100644 --- a/tools/clitkAutoCropGenericFilter.txx +++ b/tools/clitkAutoCropGenericFilter.txx @@ -37,9 +37,10 @@ template template void clitk::AutoCropGenericFilter::InitializeImageType() { - // ADD_DEFAULT_IMAGE_TYPES(Dim); + //ADD_DEFAULT_IMAGE_TYPES(Dim); ADD_IMAGE_TYPE(Dim, uchar); ADD_IMAGE_TYPE(Dim, ushort); + ADD_IMAGE_TYPE(Dim, short); // ADD_IMAGE_TYPE(Dim, uint); // ADD_IMAGE_TYPE(Dim, ulong); // ADD_IMAGE_TYPE(Dim, int); diff --git a/tools/clitkImageArithm.cxx b/tools/clitkImageArithm.cxx index 4cb22ca..e0c9821 100644 --- a/tools/clitkImageArithm.cxx +++ b/tools/clitkImageArithm.cxx @@ -17,12 +17,6 @@ ===========================================================================**/ #ifndef CLITKIMAGEARITHM_CXX #define CLITKIMAGEARITHM_CXX -/** - ------------------------------------------------- - * @file clitkImageArithm.cxx - * @author David Sarrut - * @date 23 Feb 2008 08:37:53 - -------------------------------------------------*/ // clitk include #include "clitkImageArithm_ggo.h" diff --git a/tools/clitkImageArithm.ggo b/tools/clitkImageArithm.ggo index fd01863..5d85f52 100644 --- a/tools/clitkImageArithm.ggo +++ b/tools/clitkImageArithm.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, 2=divide,\n 3=max, 4=min, 5=absdiff, 6=squareddiff, 7=difference*, 8=relativ diff\n; For 'scalar' : 0=add*, 1=multiply*, 2=inverse,\n 3=max, 4=min 5=absval 6=squareval\n 7=log 8=exp 9=sqrt 10=EPID 11=divide* 12=normalize (divide by max); \n* operations supported with vector fields as inputs." int default="0" no +option "operation" t "Type of operation : \n With another image : 0=add*, 1=multiply, 2=divide,\n 3=max, 4=min, 5=absdiff, 6=squareddiff, 7=difference*, 8=relativ diff\n; For 'scalar' : 0=add*, 1=multiply*, 2=inverse,\n 3=max, 4=min 5=absval 6=squareval\n 7=log 8=exp 9=sqrt 10=EPID 11=divide* 12=normalize (divide by max) 13=-ln(I/IO)**; \n* operations supported with vector fields as inputs. \n** for fluence image, if pixel value == 0, consider value=0.5" 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/clitkImageArithmGenericFilter.txx b/tools/clitkImageArithmGenericFilter.txx index 4c2f0a5..f304075 100644 --- a/tools/clitkImageArithmGenericFilter.txx +++ b/tools/clitkImageArithmGenericFilter.txx @@ -391,6 +391,18 @@ void clitk::ImageArithmGenericFilter::ComputeImage(Iter1 it, Ite ++ito; } break; + case 13: // -ln I/I0 + while (!it.IsAtEnd()) { + if (it.Get() == 0) { // special case for fluence image with 0 value in a pixel -> consider 0.5 + ito.Set(-log(0.5 / mScalar) ); + } + else { + ito.Set(-log(PixelTypeDownCast((double)it.Get() / mScalar)) ); + } + ++it; + ++ito; + } + break; default: // error ? std::cerr << "ERROR : the operation number (" << mTypeOfOperation << ") is not known." << std::endl; exit(-1); diff --git a/tools/clitkImageStatisticsGenericFilter.txx b/tools/clitkImageStatisticsGenericFilter.txx index 7b9c78b..f5c8235 100644 --- a/tools/clitkImageStatisticsGenericFilter.txx +++ b/tools/clitkImageStatisticsGenericFilter.txx @@ -50,15 +50,7 @@ namespace clitk if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl; UpdateWithDimAndPixelType(); } - -// else if (PixelType == "unsigned_int"){ -// if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_int..." << std::endl; -// UpdateWithDimAndPixelType(); -// } - // else if (PixelType == "char"){ - // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl; - // UpdateWithDimAndPixelType(); - // } + else if(PixelType == "double"){ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and double..." << std::endl; UpdateWithDimAndPixelType(); @@ -148,12 +140,19 @@ namespace clitk typename ResamplerType::Pointer resampler = ResamplerType::New(); resampler->SetInput(labelImage); resampler->SetOutputSpacing(input->GetSpacing()); + resampler->SetGaussianFilteringEnabled(false); resampler->Update(); labelImage = resampler->GetOutput(); + //writeImage(labelImage, "test1.mha"); + + typedef clitk::CropLikeImageFilter FilterType; + typename FilterType::Pointer crop = FilterType::New(); + crop->SetInput(labelImage); + crop->SetCropLikeImage(input); + crop->Update(); + labelImage = crop->GetOutput(); + //writeImage(labelImage, "test2.mha"); - typename itk::ImageBase::RegionType reg - = input->GetLargestPossibleRegion(); - labelImage = ResizeImageLike(labelImage, ®, 0); } else { std::cerr << "Mask image has a different size/spacing than input. Abort" << std::endl; diff --git a/vv/vvBinaryImageOverlayActor.cxx b/vv/vvBinaryImageOverlayActor.cxx index a801ba0..b4a4a3d 100644 --- a/vv/vvBinaryImageOverlayActor.cxx +++ b/vv/vvBinaryImageOverlayActor.cxx @@ -314,12 +314,23 @@ void vvBinaryImageOverlayActor::ComputeExtent(int orientation, //---------------------------------------------------------------------------- void vvBinaryImageOverlayActor::ComputeExtent(int * inExtent, int * outExtent, vtkImageData * image, vtkImageData * overlay) { + for(int i=0; i<3; i++) { + double a = (image->GetOrigin()[i] + inExtent[i*2]*image->GetSpacing()[i] - + overlay->GetOrigin()[i]) / overlay->GetSpacing()[i]; + double b = (image->GetOrigin()[i] + inExtent[i*2+1]*image->GetSpacing()[i] - + overlay->GetOrigin()[i]) / overlay->GetSpacing()[i]; + outExtent[i*2] = lrint(a); + outExtent[i*2+1] = lrint(b); + } + + /* // FIXME (original) outExtent[0] = (int)lrint(((image->GetOrigin()[0] + inExtent[0]*image->GetSpacing()[0]) - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0]); outExtent[1] = (int)lrint(((image->GetOrigin()[0] + inExtent[1]*image->GetSpacing()[0]) - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0]); outExtent[2] = (int)lrint(((image->GetOrigin()[1] + inExtent[2]*image->GetSpacing()[1]) - overlay->GetOrigin()[1]) / overlay->GetSpacing()[1]); outExtent[3] = (int)lrint(((image->GetOrigin()[1] + inExtent[3]*image->GetSpacing()[1]) - overlay->GetOrigin()[1]) / overlay->GetSpacing()[1]); outExtent[4] = (int)lrint(((image->GetOrigin()[2] + inExtent[4]*image->GetSpacing()[2]) - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2]); outExtent[5] = (int)lrint(((image->GetOrigin()[2] + inExtent[5]*image->GetSpacing()[2]) - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2]); + */ } //----------------------------------------------------------------------------