24 #include <itkImageRegionIterator.h>
26 #include "mitkPixelManipulationTool.xpm"
43 Superclass::Activated();
45 m_ToolManager->RoiDataChanged +=
47 m_OriginalImageNode = m_ToolManager->GetReferenceData(0);
49 if (m_OriginalImageNode.IsNotNull())
52 if (image.IsNotNull())
58 m_ToolManager->ActivateTool(-1);
63 m_ToolManager->RoiDataChanged -=
66 Superclass::Deactivated();
71 return "pixelmanipulation";
76 return mitkPixelManipulationTool_xpm;
85 if (m_OriginalImageNode.IsNotNull())
98 filter->SetBoundingObject(boundingObject);
99 filter->SetInput(image);
101 roi = filter->GetOutput();
107 newImage->Initialize(image);
111 AccessByItk_3(image, ITKPixelManipulation, roi, newImage, m_Value);
112 this->AddImageToDataStorage(newImage);
118 template <
typename TPixel,
unsigned int VImageDimension>
124 typedef itk::Image<TPixel, VImageDimension> itkImageType;
125 typedef itk::Image<unsigned char, 3> itkMaskType;
131 typedef itk::ImageRegionConstIterator<itkImageType> InputIteratorType;
132 typedef itk::ImageRegionIterator<itkImageType> OutputIteratorType;
133 typedef itk::ImageRegionConstIterator<itkMaskType> MaskIteratorType;
135 MaskIteratorType maskIterator(itkMask, itkMask->GetLargestPossibleRegion());
136 InputIteratorType inputIterator(originalImage, originalImage->GetLargestPossibleRegion());
137 OutputIteratorType outputIterator(itkImage, itkImage->GetLargestPossibleRegion());
139 inputIterator.GoToBegin();
140 outputIterator.GoToBegin();
141 maskIterator.GoToBegin();
143 while (!outputIterator.IsAtEnd())
145 if (maskIterator.Get())
148 outputIterator.Set(newValue);
150 outputIterator.Set(inputIterator.Get() + newValue);
153 outputIterator.Set(inputIterator.Get());
163 if (image.IsNotNull())
166 std::string name = m_OriginalImageNode->GetName();
167 name.append(
"_modified");
170 node->SetData(image);
173 m_ToolManager->GetDataStorage()->Add(node, m_OriginalImageNode);
189 m_FixedValue = value;
#define AccessByItk_3(mitkImage, itkImageTypeFunction, arg1, arg2, arg3)
itk::SmartPointer< Self > Pointer
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
superclass of all bounding objects (cylinder, cuboid,...)
Image class for storing images.
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
Class for nodes of the DataTree.