10 #include <fwItkIO/itk.hpp> 15 #include <fwData/Image.hpp> 17 #include <fwDataTools/fieldHelper/Image.hpp> 19 #include <fwGuiQt/container/QtContainer.hpp> 20 #include <fwGui/dialog/MessageDialog.hpp> 23 #include <fwServices/macros.hpp> 25 #include "basicRegistration/SImagesSubstract.hpp" 27 #include <itkSubtractImageFilter.h> 34 SImagesSubstract::SImagesSubstract() noexcept :
35 ::
fwGui::editor::IEditor(),
41 SImagesSubstract::~SImagesSubstract() noexcept
57 ::fwGuiQt::container::QtContainer::sptr qtContainer = ::fwGuiQt::container::QtContainer::dynamicCast(
58 this->getContainer() );
59 QWidget*
const container = qtContainer->getQtContainer();
60 SLM_ASSERT(
"container not instanced", container);
62 QVBoxLayout* layout =
new QVBoxLayout(container);
63 mpComputeButton =
new QPushButton(tr(
"Compute"), container );
64 QObject::connect(mpComputeButton, SIGNAL(clicked()),
this, SLOT(OnCompute()));
66 layout->addWidget(mpComputeButton, 0);
67 container->setLayout( layout );
84 ::fwData::Image::csptr image1 = this->getInput< ::fwData::Image>(
"image1");
85 ::fwData::Image::csptr image2 = this->getInput< ::fwData::Image>(
"image2");
86 ::fwData::Image::sptr imageResult = this->getInOut< ::fwData::Image>(
"result");
90 ( ((image1->getDataArray())->getType() == (image2->getDataArray())->getType())&&
91 ((image1->getDataArray())->getType() == REQUESTED_TYPE));
96 bool isSameSize = (image1->getSize() == image2->getSize());
99 typedef itk::Image< std::int16_t, 3 > ImageType;
101 ImageType::Pointer itkImage1 = ::fwItkIO::itkImageFactory< ImageType >( image1 );
102 SLM_ASSERT(
"Unable to convert fwData::Image to itkImage", itkImage1);
104 ImageType::Pointer itkImage2 = ::fwItkIO::itkImageFactory< ImageType >( image2 );
105 SLM_ASSERT(
"Unable to convert fwData::Image to itkImage", itkImage2);
107 ImageType::Pointer output;
110 typedef ::itk::SubtractImageFilter< ImageType, ImageType, ImageType > SubtractImageFilterType;
111 SubtractImageFilterType::Pointer filter;
112 filter = SubtractImageFilterType::New();
115 filter->SetInput1( itkImage1 );
116 filter->SetInput2( itkImage2 );
118 output = filter->GetOutput();
119 assert(output->GetSource());
120 ::fwItkIO::dataImageFactory< ImageType >( output, imageResult, true );
128 "Both images must have the same size.",
129 ::fwGui::dialog::IMessageDialog::WARNING);
135 "Both Images must have signed short as type.",
136 ::fwGui::dialog::IMessageDialog::WARNING);
150 void SImagesSubstract::OnCompute()
virtual BASICREGISTRATION_API void stopping() override
Overrides.
The namespace fwGui contains the base interface for IHM services.
Defines the service interface managing the editor service for object.
static FWGUI_API IMessageDialog::Buttons showMessageDialog(const std::string &title, const std::string &message,::fwGui::dialog::IMessageDialog::Icons icon=INFO)
FWGUI_API void destroy()
Stops sub-views and toobar services. Destroys view, sub-views and toolbar containers.
virtual BASICREGISTRATION_API void starting() override
Overrides.
The namespace basicRegistration contains services to perfom a basic registration between images and m...
virtual BASICREGISTRATION_API void swapping() override
Overrides.
virtual BASICREGISTRATION_API void configuring() override
Configure the service before starting. Apply the configuration to service.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWGUI_API void create()
Creates view, sub-views and toolbar containers. Manages sub-views and toobar services.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map of signal m_sigModified.
virtual BASICREGISTRATION_API void updating() override
Overrides.
Compute the substraction of two images.
This file defines SpyLog macros. These macros are used to log messages to a file or to the console du...
FWGUI_API void initialize()
Initialize managers.