diff --git a/Plugins/org.mitk.gui.qt.exampleplugin/src/internal/ExampleView.cpp b/Plugins/org.mitk.gui.qt.exampleplugin/src/internal/ExampleView.cpp index 70290874dd..b51576efb1 100644 --- a/Plugins/org.mitk.gui.qt.exampleplugin/src/internal/ExampleView.cpp +++ b/Plugins/org.mitk.gui.qt.exampleplugin/src/internal/ExampleView.cpp @@ -1,162 +1,168 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //#include <-research // Blueberry #include #include // Qmitk #include "ExampleView.h" // Qt #include #include #include #include - +#include +#include // mitk image #include #include #include #include +#include #include const std::string ExampleView::VIEW_ID = "org.mitk.views.exampleview"; void ExampleView::SetFocus() { m_Controls.buttonPerformImageProcessing->setFocus(); } void ExampleView::CreateQtPartControl(QWidget *parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); connect(m_Controls.buttonPerformImageProcessing, &QPushButton::clicked, this, &ExampleView::DoImageStatistics); connect(m_Controls.buttonGenerate, &QPushButton::clicked, this, &ExampleView::DoPixelMasking); } void ExampleView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*source*/, const QList &nodes) { // iterate all selected objects, adjust warning visibility foreach (mitk::DataNode::Pointer node, nodes) { if (node.IsNotNull() && dynamic_cast(node->GetData())) { m_Controls.labelWarning->setVisible(false); m_Controls.buttonPerformImageProcessing->setEnabled(true); + m_Controls.buttonGenerate->setEnabled(true); return; } } m_Controls.labelWarning->setVisible(true); m_Controls.buttonPerformImageProcessing->setEnabled(false); + m_Controls.buttonGenerate->setEnabled(false); } void ExampleView::DoImageStatistics() { QList nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataNode *node = nodes.front(); if (node == nullptr) { // Nothing selected. Inform the user and return QMessageBox::information(nullptr, "Warning", "Please load and select an image before starting image processing."); return; } // here we have a valid mitk::DataNode // a node itself is not very useful, we need its data item (the image) mitk::BaseData *data = node->GetData(); if (data) { // test if this data item is an image or not (could also be a surface or something totally different) mitk::Image *image = dynamic_cast(data); if (image) { - //get max - - //get min + auto statistics = image->GetStatistics(); + auto minPixelValue = statistics->GetScalarValueMin(); + auto maxPixelValue = statistics->GetScalarValueMax(); //get average //get dev } } } void ExampleView::DoPixelMasking() { this->ProcessImage(); } void ExampleView::ProcessImage() { // check for valid node selected QList nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataNode *node = nodes.front(); if (node == nullptr) { // Nothing selected. Inform the user and return QMessageBox::information(nullptr, "Warning", "Please load and select an image before starting image processing."); return; } mitk::BaseData* data = node->GetData(); //get data from node if (data != nullptr) { //Ask for the name of the mask bool ok = false; QString name = QInputDialog::getText(QApplication::activeWindow() - , tr("Add mask..."), tr("Enter name for the new mask"), QLineEdit::Normal, tr("mask"), &ok); + , tr("Add mask..."), tr("Enter name for the new mask"), QLineEdit::Normal, tr("Mask"), &ok); if (!ok || name.isEmpty()) return; - //Create a new empty pointset - // - mitk::Image::Pointer mask = mitk::Image::New(); + //Create copy image + mitk::Image *image = dynamic_cast(data); + if (image) + { + mitk::Image::Pointer maskedImage = image; + } // // Create a new data tree node // - mitk::DataNode::Pointer maskNode = mitk::DataNode::New(); + mitk::DataNode::Pointer maskedImageNode = mitk::DataNode::New(); // // fill the data tree node with the appropriate information // - maskNode->SetData(mask); - maskNode->SetProperty("name", mitk::StringProperty::New(name.toStdString())); - maskNode->SetProperty("opacity", mitk::FloatProperty::New(1)); - maskNode->SetColor(1.0, 1.0, 0.0); + maskedImageNode->SetData(image); + maskedImageNode->SetProperty("name", mitk::StringProperty::New(name.toStdString())); + maskedImageNode->SetProperty("opacity", mitk::FloatProperty::New(1)); // // add the node to the ds // - this->GetDataStorage()->Add(maskNode); + this->GetDataStorage()->Add(maskedImageNode); } } \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.exampleplugin/src/internal/ExampleViewControls.ui b/Plugins/org.mitk.gui.qt.exampleplugin/src/internal/ExampleViewControls.ui index b6e5acd889..8fad0e0310 100644 --- a/Plugins/org.mitk.gui.qt.exampleplugin/src/internal/ExampleViewControls.ui +++ b/Plugins/org.mitk.gui.qt.exampleplugin/src/internal/ExampleViewControls.ui @@ -1,124 +1,171 @@ ExampleViewControls 0 0 222 - 284 + 481 0 0 QmitkTemplate Qt::RightToLeft 1 Qt::LeftToRight Image: QLabel { color: rgb(255, 0, 0) } Please select an image! + + false + Do image processing Calculate Statistics: - + + + false + + + 4 + + + 1 + + + false + + + false + + + + max + + + + + min + + + + + dev + + + + + avg + + + + + 0 + + + Threshold + + false + Generate Qt::Vertical QSizePolicy::Expanding 20 220 QmitkDataStorageComboBox QComboBox
QmitkDataStorageComboBox.h