//--------------------------------------------------------------------
+ template<class ImageType, class LabelType>
+ typename itk::LabelMap< itk::ShapeLabelObject<LabelType, ImageType::ImageDimension> >::Pointer
+ ComputeLabelMap(const ImageType * image,
+ typename ImageType::PixelType BG,
+ bool computePerimeterFlag=false);
template<class ImageType>
void
ComputeCentroids(const ImageType * image,
//--------------------------------------------------------------------
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ typename ImageType::Pointer
+ Clone(const ImageType * input);
+ //--------------------------------------------------------------------
+
+
}
#include "clitkSegmentationUtils.txx"
#include <itkConstantPadImageFilter.h>
#include <itkImageSliceIteratorWithIndex.h>
#include <itkBinaryMorphologicalOpeningImageFilter.h>
+#include <itkImageDuplicator.h>
namespace clitk {
//--------------------------------------------------------------------
+ //--------------------------------------------------------------------
+ template<class ImageType, class LabelType>
+ typename itk::LabelMap< itk::ShapeLabelObject<LabelType, ImageType::ImageDimension> >::Pointer
+ ComputeLabelMap(const ImageType * image,
+ typename ImageType::PixelType BG,
+ bool computePerimeterFlag)
+ {
+ static const unsigned int Dim = ImageType::ImageDimension;
+ typedef itk::ShapeLabelObject< LabelType, Dim > LabelObjectType;
+ typedef itk::LabelMap< LabelObjectType > LabelMapType;
+ typedef itk::LabelImageToLabelMapFilter<ImageType, LabelMapType> ImageToMapFilterType;
+ typename ImageToMapFilterType::Pointer imageToLabelFilter = ImageToMapFilterType::New();
+ typedef itk::ShapeLabelMapFilter<LabelMapType, ImageType> ShapeFilterType;
+ typename ShapeFilterType::Pointer statFilter = ShapeFilterType::New();
+ imageToLabelFilter->SetBackgroundValue(BG);
+ imageToLabelFilter->SetInput(image);
+ statFilter->SetInput(imageToLabelFilter->GetOutput());
+ statFilter->SetComputePerimeter(computePerimeterFlag);
+ statFilter->Update();
+ return statFilter->GetOutput();
+ }
+ //--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
template<class ImageType>
void
//--------------------------------------------------------------------
+ //--------------------------------------------------------------------
+ template<class ImageType>
+ typename ImageType::Pointer
+ Clone(const ImageType * input) {
+ typedef itk::ImageDuplicator<ImageType> DuplicatorType;
+ typename DuplicatorType::Pointer duplicator = DuplicatorType::New();
+ duplicator->SetInputImage(input);
+ duplicator->Update();
+ return duplicator->GetOutput();
+ }
+ //--------------------------------------------------------------------
+
+
} // end of namespace
--- /dev/null
+/*=========================================================================
+ 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
+======================================================================-====*/
+
+// clitk
+#include "clitkBool_ggo.h"
+#include "clitkBooleanOperatorLabelImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+ // Init command line
+ GGO(clitkBool, args_info);
+ CLITK_INIT;
+
+ // Filter
+ typedef clitk::BooleanOperatorLabelImageGenericFilter<args_info_clitkBool> FilterType;
+ FilterType::Pointer filter = FilterType::New();
+
+ filter->SetArgsInfo(args_info);
+
+ try {
+ filter->Update();
+ } catch(std::runtime_error e) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_SUCCESS;
+} // This is the end, my friend
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkExtractMediastinalVessels.ggo
+package "clitkExtractMediastinalVessels"
+version "1.0"
+purpose "Extract MediastinalVessels"
+
+option "config" - "Config file" string no
+option "imagetypes" - "Display allowed image types" flag off
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input mask 1" string yes
+option "input2" j "Input mask 2" string yes
+option "output" o "Output filename" string yes
+
+option "type" t "Bool type : " int default="1" no
--- /dev/null
+/*=========================================================================
+ 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 CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_H
+#define CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_H
+
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+#include "clitkBooleanOperatorLabelImageFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+ template<class ArgsInfoType>
+ class ITK_EXPORT BooleanOperatorLabelImageGenericFilter:
+ public ImageToImageGenericFilter<BooleanOperatorLabelImageGenericFilter<ArgsInfoType> >
+ {
+
+ public:
+ //--------------------------------------------------------------------
+ BooleanOperatorLabelImageGenericFilter();
+
+ //--------------------------------------------------------------------
+ typedef ImageToImageGenericFilter<BooleanOperatorLabelImageGenericFilter<ArgsInfoType> > Superclass;
+ typedef BooleanOperatorLabelImageGenericFilter Self;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ //--------------------------------------------------------------------
+ itkNewMacro(Self);
+ itkTypeMacro(BooleanOperatorLabelImageGenericFilter, LightObject);
+
+ //--------------------------------------------------------------------
+ // Options for the GenericFilter
+ void SetArgsInfo(const ArgsInfoType & a);
+
+ //--------------------------------------------------------------------
+ // Options for the Filter
+ template<class FilterType>
+ void SetOptionsFromArgsInfoToFilter(FilterType * f) ;
+
+ //--------------------------------------------------------------------
+ // Main function called each time the filter is updated
+ template<class ImageType>
+ void UpdateWithInputImageType();
+
+ protected:
+ template<unsigned int Dim> void InitializeImageType();
+ ArgsInfoType mArgsInfo;
+
+ private:
+ BooleanOperatorLabelImageGenericFilter(const Self&); //purposely not implemented
+ void operator=(const Self&); //purposely not implemented
+
+ }; // end class
+ //--------------------------------------------------------------------
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkBooleanOperatorLabelImageGenericFilter.txx"
+#endif
+
+#endif // #define CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_H
--- /dev/null
+/*=========================================================================
+ 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 CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_TXX
+#define CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_TXX
+
+#include "clitkImageCommon.h"
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+clitk::BooleanOperatorLabelImageGenericFilter<ArgsInfoType>::BooleanOperatorLabelImageGenericFilter():
+ ImageToImageGenericFilter<Self>("BooleanOperatorLabelImage")
+{
+ // Default values
+ cmdline_parser_clitkBool_init(&mArgsInfo);
+ InitializeImageType<3>(); // Only for 3D images
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<unsigned int Dim>
+void clitk::BooleanOperatorLabelImageGenericFilter<ArgsInfoType>::InitializeImageType()
+{
+ ADD_IMAGE_TYPE(Dim, uchar); // Can add float later
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+void clitk::BooleanOperatorLabelImageGenericFilter<ArgsInfoType>::SetArgsInfo(const ArgsInfoType & a)
+{
+ mArgsInfo=a;
+ SetIOVerbose(mArgsInfo.verbose_flag);
+ if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+ if (mArgsInfo.input_given) AddInputFilename(mArgsInfo.input_arg);
+ if (mArgsInfo.input2_given) AddInputFilename(mArgsInfo.input2_arg);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<class FilterType>
+void
+clitk::BooleanOperatorLabelImageGenericFilter<ArgsInfoType>::
+SetOptionsFromArgsInfoToFilter(FilterType * f)
+{
+ // Operation type
+ f->SetOperationType(typename FilterType::OperationTypeEnumeration(mArgsInfo.type_arg));
+
+ // Output filename
+ this->AddOutputFilename(mArgsInfo.output_arg);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<class ImageType>
+void clitk::BooleanOperatorLabelImageGenericFilter<ArgsInfoType>::UpdateWithInputImageType()
+{
+ // Reading input
+ typename ImageType::Pointer input1 = this->template GetInput<ImageType>(0);
+ typename ImageType::Pointer input2 = this->template GetInput<ImageType>(1);
+
+ // Create filter
+ typedef clitk::BooleanOperatorLabelImageFilter<ImageType> FilterType;
+ typename FilterType::Pointer filter = FilterType::New();
+
+ // Set global Options
+ filter->SetInput1(input1);
+ filter->SetInput2(input2);
+ SetOptionsFromArgsInfoToFilter<FilterType>(filter);
+
+ // Go !
+ filter->Update();
+
+ // Write/Save results
+ typename ImageType::Pointer output = filter->GetOutput();
+ this->template SetNextOutput<ImageType>(output);
+}
+//--------------------------------------------------------------------
+
+#endif //#define CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_TXX
output->SetOrigin(origin);
}
- // force index to zero
- typename ImageType::RegionType region;
- region = output->GetLargestPossibleRegion();
- typename ImageType::IndexType index;
+ // adjust image origin and force index to zero
+ typename ImageType::RegionType region = output->GetLargestPossibleRegion();
+ typename ImageType::IndexType index = region.GetIndex();
+ typename ImageType::PointType origin = output->GetOrigin();
+ typename ImageType::SpacingType spacing = output->GetSpacing();
+ if (mArgsInfo.verbose_flag) std::cout << "origin before crop " << origin << std::endl;
+ for (unsigned int i = 0; i < output->GetImageDimension(); i++)
+ origin[i] += index[i]*spacing[i];
+ if (mArgsInfo.verbose_flag) std::cout << "origin after crop " << origin << std::endl;
+ output->SetOrigin(origin);
+
index.Fill(itk::NumericTraits<double>::Zero);
region.SetIndex(index);
output->SetRegions(region);
-
+
// Write/Save results
this->template SetNextOutput<ImageType>(output);
}
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" 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)" 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
#include "clitkImageCommon.h"
+#include "itkMinimumMaximumImageCalculator.h"
+
namespace clitk
{
typename ImageType::Pointer input2 = NULL;
IteratorType it2;
+ // Special case for normalisation
+ if (mTypeOfOperation == 12) {
+ typedef itk::MinimumMaximumImageCalculator<ImageType> MinMaxFilterType;
+ typename MinMaxFilterType::Pointer ff = MinMaxFilterType::New();
+ ff->SetImage(input1);
+ ff->ComputeMaximum();
+ mScalar = ff->GetMaximum();
+ mTypeOfOperation = 11; // divide
+ }
if (mIsOperationUseASecondImage) {
// Read input2
++ito;
}
break;
+ case 11: // divide
+ while (!it.IsAtEnd()) {
+ ito.Set(PixelTypeDownCast<double, PixelType>((double)it.Get() / mScalar) );
+ ++it;
+ ++ito;
+ }
+ break;
default: // error ?
std::cerr << "ERROR : the operation number (" << mTypeOfOperation << ") is not known." << std::endl;
exit(-1);
<file>icons/adjustsize.png</file>
<file>icons/standardbutton-apply-16.png</file>
<file>icons/standardbutton-cancel-16.png</file>
+ <file>icons/identity.png</file>
</qresource>
</RCC>
//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-void vvInfoPanel::setViews(int window, int view, int slice)
-{/*
- QString viewString;
- switch (view) {
- case 0: {
- viewString = "Sagital, ";
- break;
- }
- case 1: {
- viewString = "Coronal, ";
- break;
- }
- case 2: {
- viewString = "Axial, ";
- break;
- }
- }
-
- QString text = viewString;
- if (view != -1) {
- text += "current slice : ";
- text += QString::number(slice);
- } else {
- text = "Disable";
- }
-
- switch (window) {
- case 0: {
- ULLabel->setText(text);
- break;
- }
- case 1: {
- URLabel->setText(text);
- break;
- }
- case 2: {
- DLLabel->setText(text);
- break;
- }
- case 3: {
- DRLabel->setText(text);
- break;
- }
- }*/
-}
-//------------------------------------------------------------------------------
-
-
//------------------------------------------------------------------------------
void vvInfoPanel::setMemoryInMb(QString text)
{
void setDimension(QString text);
void setSizePixel(QString text);
void setCurrentInfo(int visibility, double x, double y, double z, double X, double Y, double Z, double value);
- void setViews(int window, int view, int slice);
void setMemoryInMb(QString text);
public slots:
connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(SelectFusionImage()));
contextActions.push_back(actionAdd_fusion_image);
+ contextMenu.addSeparator();
+ QAction* actionResetMatrix = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/identity.png")),
+ tr("Reset transformation to identity"));
+ connect(actionResetMatrix, SIGNAL(triggered()), this,SLOT(ResetTransformationToIdentity()));
+
// TRIAL DS
/*
QMenu * m = new QMenu(menubar);
this, SLOT(OverlayChanged(int,double,double)));
connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
this, SLOT(FusionChanged(int,double)));
- connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)),
- this,SLOT(WindowsChanged(int, int, int)));
connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
this,SLOT(WindowLevelChanged(double, double, int, int)));
connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
}
//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-void vvMainWindow::WindowsChanged(int window, int view, int slice)
-{
- infoPanel->setViews(window, view, slice);
-}
-//------------------------------------------------------------------------------
-
//------------------------------------------------------------------------------
void vvMainWindow::WindowLevelChanged(double window, double level,int preset,int colormap)
{
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvMainWindow::ResetTransformationToIdentity()
+{
+ std::string actorType = DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString().toStdString();
+ int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+ mSlicerManagers[index]->ResetTransformationToIdentity(actorType);
+ ImageInfoChanged();
+}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::AddFusionImage(int index, QString file)
{
this, SLOT(OverlayChanged(int,double,double)));
connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
this, SLOT(FusionChanged(int,double)));
- connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)),
- this,SLOT(WindowsChanged(int, int, int)));
connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
this,SLOT(WindowLevelChanged(double, double, int, int)));
connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
void SegmentationOnCurrentImage();
void SurfaceViewerLaunch();
- void WindowsChanged(int window, int view, int slice);
void WindowLevelChanged(double window, double level,int preset, int colormap);
void UpdateSlice(int slicer, int slice);
void UpdateTSlice(int slicer, int slice);
void OpenField();
void SelectOverlayImage();
void SelectFusionImage();
+ void ResetTransformationToIdentity();
void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
void SetOverlayProperty(int color);
};
-#include "vvMainWindow.txx"
-
#endif
+++ /dev/null
-/*=========================================================================
- 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://www.centreleonberard.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
-===========================================================================**/
-// }
// Overlay image actor
if (mOverlay && mOverlayActor->GetVisibility()) {
+ AdjustResliceToSliceOrientation(mOverlayReslice);
int overExtent[6];
- mOverlayReslice->GetOutput()->UpdateInformation();
this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
mOverlayActor->SetDisplayExtent( overExtent );
// Fusion image actor
if (mFusion && mFusionActor->GetVisibility()) {
+ AdjustResliceToSliceOrientation(mFusionReslice);
int fusExtent[6];
- mFusionReslice->GetOutput()->UpdateInformation();
this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
mFusionActor->SetDisplayExtent(fusExtent);
}
//----------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType)
+{
+ if(actorType == "image")
+ this->GetImage()->GetTransform()->Identity();
+ else if(actorType == "overlay")
+ this->GetSlicer(0)->GetOverlay()->GetTransform()->Identity();
+ else if(actorType == "fusion")
+ this->GetSlicer(0)->GetFusion()->GetTransform()->Identity();
+ else if(actorType == "vf")
+ this->GetVF()->GetTransform()->Identity();
+ else
+ return;
+
+ for(int i=0; i< this->GetNumberOfSlicers(); i++){
+ this->GetSlicer(i)->ForceUpdateDisplayExtent();
+ this->GetSlicer(i)->ResetCamera();
+ this->GetSlicer(i)->Render();
+ }
+}
+//------------------------------------------------------------------------------
//----------------------------------------------------------------------------
void vvSlicerManager::Render()
void UpdateViews(int current, int slicer);
void UpdateLinked(int slicer);
void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
+ void ResetTransformationToIdentity(const std::string actorType);
void Render();
void AddLink(std::string newId) {
void UpdateVector(int display, double x, double y, double z, double value);
void UpdateOverlay(int display, double valueOver, double valueRef);
void UpdateFusion(int display, double valueFus);
- void UpdateWindows(int slicer, int view, int slice);
void UpdateOrientation(int slicer, int orientation);
void UpdateSlice(int slicer, int slice);
void UpdateTSlice(int slicer, int slice);