Page MenuHomePhabricator

patch-1665

Authored By
curi
Oct 9 2008, 10:50 AM
Size
26 KB
Referenced Files
None
Subscribers
None

patch-1665

Index: mitk/Core/Interactions/mitkCalculateGrayValueStatisticsTool.h
===================================================================
--- mitk/Core/Interactions/mitkCalculateGrayValueStatisticsTool.h (Revision 15406)
+++ mitk/Core/Interactions/mitkCalculateGrayValueStatisticsTool.h (Arbeitskopie)
@@ -1,5 +1,5 @@
/*=========================================================================
-
+
Program: Medical Imaging & Interaction Toolkit
Module: $RCSfile: mitk.cpp,v $
Language: C++
@@ -13,7 +13,7 @@
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
-
+
=========================================================================*/
#ifndef mitkCalculateGrayValueStatisticsTool_h_Included
@@ -29,43 +29,63 @@
{
/**
- \brief Calculates some gray value statistics for segmentations.
+ \brief Calculates some gray value statistics for segmentations.
- \ingroup Reliver
- \sa mitk::Tool
- \sa QmitkInteractiveSegmentation
+ \ingroup Reliver
+ \sa mitk::Tool
+ \sa QmitkInteractiveSegmentation
- Last contributor: $Author$
+ Last contributor: $Author$
*/
class MITK_CORE_EXPORT CalculateGrayValueStatisticsTool : public SegmentationsProcessingTool
{
public:
-
- Message StatisticsCompleted;
-
+
+ Message StatisticsCompleted;
+
mitkClassMacro(CalculateGrayValueStatisticsTool, SegmentationsProcessingTool);
itkNewMacro(CalculateGrayValueStatisticsTool);
- virtual const char** GetXPM() const;
- virtual const char* GetName() const;
+ virtual const char** GetXPM() const;
+ virtual const char* GetName() const;
- virtual std::string GetReport() const;
+ virtual std::string GetReport() const;
- protected:
-
- CalculateGrayValueStatisticsTool(); // purposely hidden
- virtual ~CalculateGrayValueStatisticsTool();
-
- virtual void StartProcessingAllData();
+ typedef itk::Statistics::Histogram<float, 1> HistogramType;
+ HistogramType::Pointer m_ITKHistogram;
+
+ HistogramType::ConstPointer GetHistogram();
+
+ typedef HistogramType::MeasurementType HistogramMeasurementType;
+
+protected:
+
+ CalculateGrayValueStatisticsTool(); // purposely hidden
+ virtual ~CalculateGrayValueStatisticsTool();
+
+ virtual void StartProcessingAllData();
virtual bool ProcessOneWorkingData( DataTreeNode* node );
- virtual void FinishProcessingAllData();
+ virtual void FinishProcessingAllData();
- virtual std::string GetErrorMessage();
+ virtual std::string GetErrorMessage();
- template <typename TPixel, unsigned int VImageDimension>
- void ITKHistogramming( itk::Image<TPixel, VImageDimension>* referenceImage, Image* segmentation, std::stringstream& report );
+ /**
+ Calculates the minimum and maximum of the pixelvalues. They have to be known to initialize the histogram.
+ */
+ template<typename TPixel, unsigned int VImageDimension>
+ void CalculateMinMax(itk::Image<TPixel, VImageDimension>* referenceImage, Image* segmentation,
+ TPixel& minimum, TPixel& maximum);
- std::stringstream m_CompleteReport;
+ /**
+ - initializes and fills the histogram
+ - calculates mean, sd and quantiles
+ */
+ template<typename TPixel, unsigned int VImageDimension>
+ void ITKHistogramming(itk::Image<TPixel, VImageDimension>* referenceImage, Image* segmentation,
+ std::stringstream& report);
+
+ std::stringstream m_CompleteReport;
+
};
} // namespace
Index: mitk/Core/Interactions/mitkCalculateGrayValueStatisticsTool.cpp
===================================================================
--- mitk/Core/Interactions/mitkCalculateGrayValueStatisticsTool.cpp (Revision 15406)
+++ mitk/Core/Interactions/mitkCalculateGrayValueStatisticsTool.cpp (Arbeitskopie)
@@ -1,5 +1,5 @@
/*=========================================================================
-
+
Program: Medical Imaging & Interaction Toolkit
Module: $RCSfile: mitkPropertyManager.cpp,v $
Language: C++
@@ -13,7 +13,7 @@
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
-
+
=========================================================================*/
#include "mitkCalculateGrayValueStatisticsTool.h"
@@ -27,8 +27,9 @@
#include "mitkToolManager.h"
#include <itkCommand.h>
-#include <itkMapContainer.h>
+#include <itkHistogram.h>
+
mitk::CalculateGrayValueStatisticsTool::CalculateGrayValueStatisticsTool()
{
}
@@ -57,17 +58,17 @@
// clear/prepare report
m_CompleteReport.str("");
}
-
+
bool mitk::CalculateGrayValueStatisticsTool::ProcessOneWorkingData( DataTreeNode* node )
{
if (node)
{
Image::Pointer image = dynamic_cast<Image*>( node->GetData() );
if (image.IsNull()) return false;
-
+
DataTreeNode* referencenode = m_ToolManager->GetReferenceData(0);
if (!referencenode) return false;
-
+
try
{
ProgressBar::GetInstance()->AddStepsToDo(1);
@@ -75,7 +76,7 @@
// add to report
std::string nodename("structure");
node->GetName(nodename);
-
+
std::string message = "Calculating statistics for ";
message += nodename;
@@ -83,9 +84,9 @@
Image::Pointer refImage = dynamic_cast<Image*>( referencenode->GetData() );
Image::Pointer image = dynamic_cast<Image*>( node->GetData() );
-
+
m_CompleteReport << "======== Gray value analysis of " << nodename << " ========\n";
-
+
if (image.IsNotNull() && refImage.IsNotNull() )
{
for (unsigned int timeStep = 0; timeStep < image->GetTimeSteps(); ++timeStep)
@@ -109,7 +110,7 @@
}
}
}
-
+
m_CompleteReport << "======== End of analysis for " << nodename << " ===========\n\n\n";
ProgressBar::GetInstance()->Progress();
@@ -133,38 +134,107 @@
}
#define ROUND_P(x) ((int)((x)+0.5))
-
-template <typename TPixel, unsigned int VImageDimension>
-void mitk::CalculateGrayValueStatisticsTool::ITKHistogramming( itk::Image<TPixel, VImageDimension>* referenceImage, Image* segmentation, std::stringstream& report )
+
+template<typename TPixel, unsigned int VImageDimension>
+void mitk::CalculateGrayValueStatisticsTool::CalculateMinMax(
+ itk::Image<TPixel, VImageDimension>* referenceImage, Image* segmentation, TPixel& minimum,
+ TPixel& maximum)
{
typedef itk::Image<TPixel, VImageDimension> ImageType;
typedef itk::Image<Tool::DefaultSegmentationDataType, VImageDimension> SegmentationType;
typename SegmentationType::Pointer segmentationItk;
+ CastToItkImage(segmentation, segmentationItk);
+
+ typename SegmentationType::RegionType segmentationRegion =
+ segmentationItk->GetLargestPossibleRegion();
+
+ segmentationRegion.Crop(referenceImage->GetLargestPossibleRegion());
+
+ itk::ImageRegionConstIteratorWithIndex<SegmentationType> segmentationIterator(segmentationItk,
+ segmentationRegion);
+ itk::ImageRegionConstIteratorWithIndex<ImageType> referenceIterator(referenceImage,
+ segmentationRegion);
+
+ segmentationIterator.GoToBegin();
+ referenceIterator.GoToBegin();
+
+ minimum = std::numeric_limits<TPixel>::max();
+ maximum = std::numeric_limits<TPixel>::min();
+
+ while (!segmentationIterator.IsAtEnd())
+ {
+ itk::Point<float, 3> pt;
+ segmentationItk->TransformIndexToPhysicalPoint(segmentationIterator.GetIndex(), pt);
+
+ typename ImageType::IndexType ind;
+ itk::ContinuousIndex<float, 3> contInd;
+ if (referenceImage->TransformPhysicalPointToContinuousIndex(pt, contInd))
+ {
+ for (unsigned int i = 0; i < 3; ++i)
+ ind[i] = ROUND_P(contInd[i]);
+
+ referenceIterator.SetIndex(ind);
+
+ if (segmentationIterator.Get() > 0)
+ {
+
+ if (referenceIterator.Get() < minimum)
+ minimum = referenceIterator.Get();
+ if (referenceIterator.Get() > maximum)
+ maximum = referenceIterator.Get();
+ }
+ }
+
+ ++segmentationIterator;
+ }
+
+}
+
+template<typename TPixel, unsigned int VImageDimension>
+void mitk::CalculateGrayValueStatisticsTool::ITKHistogramming(
+ itk::Image<TPixel, VImageDimension>* referenceImage, Image* segmentation,
+ std::stringstream& report)
+{
+ typedef itk::Image<TPixel, VImageDimension> ImageType;
+ typedef itk::Image<Tool::DefaultSegmentationDataType, VImageDimension> SegmentationType;
+
+ typename SegmentationType::Pointer segmentationItk;
CastToItkImage( segmentation, segmentationItk );
-
+
// generate histogram
typename SegmentationType::RegionType segmentationRegion = segmentationItk->GetLargestPossibleRegion();
segmentationRegion.Crop( referenceImage->GetLargestPossibleRegion() );
-
+
itk::ImageRegionConstIteratorWithIndex< SegmentationType > segmentationIterator( segmentationItk, segmentationRegion);
itk::ImageRegionConstIteratorWithIndex< ImageType > referenceIterator( referenceImage, segmentationRegion);
segmentationIterator.GoToBegin();
referenceIterator.GoToBegin();
-
- typedef itk::MapContainer<TPixel, long int> HistogramType;
+
+ m_ITKHistogram = HistogramType::New();
+
TPixel minimum = std::numeric_limits<TPixel>::max();
TPixel maximum = std::numeric_limits<TPixel>::min();
- HistogramType histogram;
-
+
+ CalculateMinMax(referenceImage, segmentation, minimum, maximum);
+
+ //initialize the histogram to the range of the cropped region
+ HistogramType::SizeType size;
+ size.Fill(static_cast<HistogramType::SizeType::SizeValueType> (maximum - minimum + 1));
+ HistogramType::MeasurementVectorType lowerBound;
+ HistogramType::MeasurementVectorType upperBound;
+ lowerBound[0] = minimum;
+ upperBound[0] = maximum;
+ m_ITKHistogram->Initialize(size, lowerBound, upperBound);
+
double mean(0.0);
double sd(0.0);
double voxelCount(0.0);
- // first pass for mean, min, max, histogram values
- while ( !segmentationIterator.IsAtEnd() )
+ //iterate through the cropped region add the values to the histogram
+ while (!segmentationIterator.IsAtEnd())
{
itk::Point< float, 3 > pt;
segmentationItk->TransformIndexToPhysicalPoint( segmentationIterator.GetIndex(), pt );
@@ -174,18 +244,21 @@
if (referenceImage->TransformPhysicalPointToContinuousIndex(pt, contInd))
{
for (unsigned int i = 0; i < 3; ++i) ind[i] = ROUND_P(contInd[i]);
-
+
referenceIterator.SetIndex( ind );
if ( segmentationIterator.Get() > 0 )
{
- ++histogram[referenceIterator.Get()];
- if (referenceIterator.Get() < minimum) minimum = referenceIterator.Get();
- if (referenceIterator.Get() > maximum) maximum = referenceIterator.Get();
-
- mean = (mean * ( static_cast<double>(voxelCount) / static_cast<double>(voxelCount+1) ) ) // 3 points: old center * 2/3 + currentPoint * 1/3;
- + static_cast<double>(referenceIterator.Get() ) / static_cast<double>(voxelCount+1);
+ HistogramType::MeasurementVectorType currentMeasurementVector;
+
+ currentMeasurementVector[0]
+ = static_cast<HistogramType::MeasurementType> (referenceIterator.Get());
+ m_ITKHistogram->IncreaseFrequency(currentMeasurementVector, 1);
+
+ mean = (mean * (static_cast<double> (voxelCount) / static_cast<double> (voxelCount + 1))) // 3 points: old center * 2/3 + currentPoint * 1/3;
+ + static_cast<double> (referenceIterator.Get()) / static_cast<double> (voxelCount + 1);
+
voxelCount += 1.0;
}
}
@@ -206,7 +279,7 @@
if (referenceImage->TransformPhysicalPointToContinuousIndex(pt, contInd))
{
for (unsigned int i = 0; i < 3; ++i) ind[i] = ROUND_P(contInd[i]);
-
+
referenceIterator.SetIndex( ind );
if ( segmentationIterator.Get() > 0 )
@@ -221,56 +294,25 @@
sd /= static_cast<double>(voxelCount - 1);
sd = sqrt( sd );
- // evaluate histogram, generate quantiles
- long int totalCount(0);
+ // generate quantiles
+ TPixel histogramQuantileValues[5];
+ histogramQuantileValues[0] = m_ITKHistogram->Quantile(0, 0.05);
+ histogramQuantileValues[1] = m_ITKHistogram->Quantile(0, 0.25);
+ histogramQuantileValues[2] = m_ITKHistogram->Quantile(0, 0.50);
+ histogramQuantileValues[3] = m_ITKHistogram->Quantile(0, 0.75);
+ histogramQuantileValues[4] = m_ITKHistogram->Quantile(0, 0.95);
- for ( typename HistogramType::iterator iter = histogram.begin();
- iter != histogram.end();
- ++iter )
- {
- totalCount += iter->second;
- }
-
- TPixel histogramQuantileValues[102];
-
- double quantiles[102];
- for (unsigned int i = 0; i < 102; ++i) quantiles[i] = static_cast<double>(i) / 100.0; quantiles[102-1] = 2.0;
-
- for (unsigned int i = 0; i < 102; ++i) histogramQuantileValues[i] = 0;
-
- int currentQuantile(0);
-
- double relativeCurrentCount(0.0);
-
- for ( typename HistogramType::iterator iter = histogram.begin();
- iter != histogram.end();
- ++iter )
- {
- TPixel grayvalue = iter->first;
- long int count = iter->second;
-
- double relativeCount = static_cast<double>(count) / static_cast<double>(totalCount);
-
- relativeCurrentCount += relativeCount;
-
- while ( relativeCurrentCount >= quantiles[currentQuantile] )
- {
- histogramQuantileValues[currentQuantile] = grayvalue;
- ++currentQuantile;
- }
- }
-
// report histogram values
- report << " Minimum: " << minimum
- << "\n 5% quantile: " << histogramQuantileValues[5]
- << "\n 25% quantile: " << histogramQuantileValues[25]
- << "\n 50% quantile: " << histogramQuantileValues[50]
- << "\n 75% quantile: " << histogramQuantileValues[75]
- << "\n 95% quantile: " << histogramQuantileValues[95]
- << "\n Maximum: " << maximum
- << "\n Mean: " << mean
- << "\n SD: " << sd
- << "\n";
+ report << " Minimum:" << minimum
+ << "\n 5% quantile: " << histogramQuantileValues[0]
+ << "\n 25% quantile: " << histogramQuantileValues[1]
+ << "\n 50% quantile: " << histogramQuantileValues[2]
+ << "\n 75% quantile: " << histogramQuantileValues[3]
+ << "\n 95% quantile: " << histogramQuantileValues[4]
+ << "\n Maximum: " << maximum
+ << "\n Mean: " << mean
+ << "\n SD: " << sd
+ << "\n";
}
std::string mitk::CalculateGrayValueStatisticsTool::GetReport() const
@@ -278,3 +320,8 @@
return m_CompleteReport.str();
}
+mitk::CalculateGrayValueStatisticsTool::HistogramType::ConstPointer mitk::CalculateGrayValueStatisticsTool::GetHistogram()
+{
+ return m_ITKHistogram.GetPointer();
+}
+
Index: mitk/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h
===================================================================
--- mitk/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h (Revision 15406)
+++ mitk/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h (Arbeitskopie)
@@ -1,5 +1,5 @@
/*=========================================================================
-
+
Program: Medical Imaging & Interaction Toolkit
Module: $RCSfile: mitk.cpp,v $
Language: C++
@@ -13,7 +13,7 @@
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
-
+
=========================================================================*/
#ifndef QmitkCalculateGrayValueStatisticsToolGUI_h_Included
@@ -24,30 +24,33 @@
#include "mitkCalculateGrayValueStatisticsTool.h"
/**
- \brief GUI for mitk::CalculateGrayValueStatisticsTool.
+ \brief GUI for mitk::CalculateGrayValueStatisticsTool.
- Shows nothing. Only when the corresponding tool send a message that statistics are ready, this class pops up a window showing the results.
+ Shows nothing. Only when the corresponding tool send a message that statistics are ready, this class pops up a window showing the results.
- Last contributor: $Author$
+ Last contributor: $Author$
*/
class QMITK_EXPORT QmitkCalculateGrayValueStatisticsToolGUI : public QmitkToolGUI
{
Q_OBJECT
public:
-
+
mitkClassMacro(QmitkCalculateGrayValueStatisticsToolGUI, QmitkToolGUI);
itkNewMacro(QmitkCalculateGrayValueStatisticsToolGUI);
-
- virtual ~QmitkCalculateGrayValueStatisticsToolGUI();
- /// Reacts to signals from mitk::CalculateGrayValueStatisticsTool
- void OnCalculationsDone();
+ virtual ~QmitkCalculateGrayValueStatisticsToolGUI();
+ /**
+ - reacts to signals from mitk::CalculateGrayValueStatisticsTool
+ - shows the histogram and report widget
+ */
+ void OnCalculationsDone();
+
signals:
public slots:
-
+
protected slots:
/// Connected to signal from QmitkToolGUI. We remember the current tool here
Index: mitk/Qmitk/files.cmake
===================================================================
--- mitk/Qmitk/files.cmake (Revision 15406)
+++ mitk/Qmitk/files.cmake (Arbeitskopie)
@@ -38,6 +38,7 @@
QmitkFunctionalityComponents/QmitkSurfaceTransformerComponent.cpp
QmitkFunctionalityComponents/QmitkThresholdComponent.cpp
QmitkHelpBrowser.cpp
+ QmitkHistogramValuesWidget.cpp
QmitkInteractionFunctionalityComponent.cpp
QmitkLevelWindowWidgetContextMenu.cpp
QmitkLineEditLevelWindowWidget.cpp
@@ -161,6 +162,7 @@
QmitkFunctionalityComponents/QmitkSurfaceTransformerComponent.h
QmitkFunctionalityComponents/QmitkThresholdComponent.h
QmitkHelpBrowser.h
+ QmitkHistogramValuesWidget.h
QmitkInteractionFunctionalityComponent.h
QmitkLevelWindowWidgetContextMenu.h
QmitkLineEditLevelWindowWidget.h
Index: mitk/Qmitk/QmitkHistogramValuesWidget.h
===================================================================
--- mitk/Qmitk/QmitkHistogramValuesWidget.h (Revision 0)
+++ mitk/Qmitk/QmitkHistogramValuesWidget.h (Revision 0)
@@ -0,0 +1,69 @@
+/*=========================================================================
+
+Program: Medical Imaging & Interaction Toolkit
+Module: $RCSfile: mitkPropertyManager.cpp,v $
+Language: C++
+Date: $Date: 2005/06/28 12:37:25 $
+Version: $Revision: 1.12 $
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef QMITKHISTOGRAMVALUESWIDGET_H_
+#define QMITKHISTOGRAMVALUESWIDGET_H_
+
+#include <qlayout.h>
+#include <qwt_plot.h>
+#include <qtextedit.h>
+#include <qdialog.h>
+
+#include <itkHistogram.h>
+
+#include "mitkCalculateGrayValueStatisticsTool.h"
+
+/**
+ \brief Shows a histogram in a Qwt_Plot and a report (selectable) in a QTextEdit
+ Makes the data Values from a itk::histogram suitable for a Qwt_Plot.
+ */
+class QmitkHistogramValuesWidget: public QDialog
+{
+Q_OBJECT
+
+public:
+
+ //overloaded constructor to choose between showing only the histogram or the histogram and the report
+ QmitkHistogramValuesWidget(bool showreport = true, QWidget *parent = 0);
+ virtual ~QmitkHistogramValuesWidget();
+
+ typedef itk::Statistics::Histogram<float, 1> HistogramType;
+
+ /**
+ - gets the data values from the histogram
+ - copies them into data arrays suitable for qwt
+ - creates a plot dialog, fill it with the data and show it
+ */
+ void SetHistogram(HistogramType::ConstPointer histogram);
+
+ void SetReport(std::string report);
+
+ typedef double QwtValueType;
+
+protected:
+
+ HistogramType::ConstPointer m_Histogram;
+ mitk::CalculateGrayValueStatisticsTool::Pointer m_CalculateGrayValueStatisticsTool;
+
+ QwtPlot* m_Plot;
+ QTextEdit* m_textedit;
+
+};
+
+#endif /* QMITKHISTOGRAMVALUESWIDGET_H_ */
+
Index: mitk/Qmitk/QmitkHistogramValuesWidget.cpp
===================================================================
--- mitk/Qmitk/QmitkHistogramValuesWidget.cpp (Revision 0)
+++ mitk/Qmitk/QmitkHistogramValuesWidget.cpp (Revision 0)
@@ -0,0 +1,124 @@
+/*=========================================================================
+
+Program: Medical Imaging & Interaction Toolkit
+Module: $RCSfile: mitkPropertyManager.cpp,v $
+Language: C++
+Date: $Date: 2005/06/28 12:37:25 $
+Version: $Revision: 1.12 $
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#include "QmitkHistogramValuesWidget.h"
+
+#include <qlayout.h>
+#include <qvgroupbox.h>
+#include <iostream>
+
+QmitkHistogramValuesWidget::QmitkHistogramValuesWidget(bool showreport, QWidget *parent)
+{
+
+ QBoxLayout *layout = new QVBoxLayout(this);
+
+ //***histogram***
+
+ QVGroupBox *hgroupbox = new QVGroupBox("Histogram", this, "histogram");
+
+ hgroupbox->setMinimumSize(900, 400);
+
+ m_Plot = new QwtPlot("H i s t o g r a m", hgroupbox);
+
+ m_Plot->setTitleFont(QFont("Helvetica", 14, QFont::Bold));
+ m_Plot->enableAxis(QwtPlot::yLeft, true);
+ m_Plot->setCanvasBackground(Qt::white);
+ m_Plot->enableOutline(true);
+ m_Plot->setOutlinePen(green);
+
+ //x-axis format
+ m_Plot->setAxisTitle(QwtPlot::xBottom, "Gray value");
+ m_Plot->setAxisTitleAlignment(QwtPlot::xBottom, Qt::AlignRight);
+ m_Plot->setAxisTitleFont(QwtPlot::xBottom, QFont("Helvetica", 12, QFont::Normal));
+ m_Plot->setAxisLabelFormat(QwtPlot::xBottom, 'f', 0);
+
+ //y-axis format
+ m_Plot->setAxisTitle(QwtPlot::yLeft, "Frequency");
+ m_Plot->setAxisTitleAlignment(QwtPlot::yLeft, Qt::AlignRight);
+ m_Plot->setAxisTitleFont(QwtPlot::yLeft, QFont("Helvetica", 12, QFont::Normal));
+ m_Plot->setAxisLabelFormat(QwtPlot::yLeft, 'f', 0);
+
+ layout->addWidget(hgroupbox);
+
+ layout->setSpacing(20);
+
+ if (showreport == true)
+ {
+
+ //***report***
+
+ QVGroupBox *rgroupbox = new QVGroupBox("Report", this, "report");
+
+ rgroupbox->setMinimumSize(900, 400);
+
+ QLabel *label = new QLabel("G r a y V a l u e A n a l y s i s", rgroupbox, "report");
+ label->setAlignment(AlignHCenter);
+ label->setFont(QFont("Helvetica", 14, QFont::Bold));
+
+ m_textedit = new QTextEdit(rgroupbox);
+ m_textedit->setFont(QFont("Helvetica", 12, QFont::Normal));
+ m_textedit->setReadOnly(true);
+
+ layout->addWidget(rgroupbox);
+ }
+
+}
+
+QmitkHistogramValuesWidget::~QmitkHistogramValuesWidget()
+{
+
+}
+
+void QmitkHistogramValuesWidget::SetHistogram(HistogramType::ConstPointer histogram)
+{
+
+ HistogramType::SizeType size = histogram->GetSize();
+ HistogramType::IndexType index;
+ HistogramType::MeasurementVectorType currentMeasurementVector;
+ QwtValueType* xValues = new QwtValueType[size[0]];
+ QwtValueType* yValues = new QwtValueType[size[0]];
+
+ for (size_t i = 0; i < size[0]; ++i)
+ {
+ index[0] = static_cast<HistogramType::IndexType::IndexValueType> (i);
+ currentMeasurementVector = histogram->GetMeasurementVector(index);
+ if (currentMeasurementVector[0] != 0.0)
+ {
+ xValues[i] = static_cast<QwtValueType> (currentMeasurementVector[0]);
+ yValues[i] = static_cast<QwtValueType> (histogram->GetFrequency(index));
+ }
+ }
+
+ m_Plot->removeCurves();
+ long curveId = m_Plot->insertCurve("Histogram");
+ m_Plot->setCurveData(curveId, xValues, yValues, size[0]);
+ m_Plot->setCurvePen(curveId, QPen(red));
+ m_Plot->setCurveTitle(curveId, "Histogram");
+ m_Plot->setCurveStyle(curveId, QwtCurve::Steps);
+ m_Plot->replot();
+
+ delete[] xValues;
+ delete[] yValues;
+
+}
+
+void QmitkHistogramValuesWidget::SetReport(std::string report)
+{
+ m_textedit->setText(report);
+}
+
Index: mitk/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.cpp
===================================================================
--- mitk/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.cpp (Revision 15406)
+++ mitk/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.cpp (Arbeitskopie)
@@ -1,5 +1,5 @@
/*=========================================================================
-
+
Program: Medical Imaging & Interaction Toolkit
Module: $RCSfile: mitkPropertyManager.cpp,v $
Language: C++
@@ -13,15 +13,17 @@
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
-
+
=========================================================================*/
#include "QmitkCalculateGrayValueStatisticsToolGUI.h"
-#include "QmitkCopyToClipBoardDialog.h"
+#include "QmitkHistogramValuesWidget.h"
-QmitkCalculateGrayValueStatisticsToolGUI::QmitkCalculateGrayValueStatisticsToolGUI()
-:QmitkToolGUI()
+#include "mitkCalculateGrayValueStatisticsTool.h"
+
+QmitkCalculateGrayValueStatisticsToolGUI::QmitkCalculateGrayValueStatisticsToolGUI() :
+ QmitkToolGUI()
{
connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) );
}
@@ -53,14 +55,20 @@
{
if (m_CalculateGrayValueStatisticsTool.IsNotNull())
{
+
+ //uses the parameter "true" because the report should be shown in addition to the histogram
+ QmitkHistogramValuesWidget* hvw = new QmitkHistogramValuesWidget(true);
+
+ typedef itk::Statistics::Histogram<float, 1> HistogramType;
+
+ HistogramType::ConstPointer histogram = m_CalculateGrayValueStatisticsTool->GetHistogram();
+ hvw->SetHistogram(histogram);
+
std::string report = m_CalculateGrayValueStatisticsTool->GetReport();
-
- // one for linux users
- std::cout << report << std::endl;
+ hvw->SetReport(report);
- // one for window users
- QmitkCopyToClipBoardDialog* dialog = new QmitkCopyToClipBoardDialog( report.c_str(), NULL);
- dialog->show();
+ hvw->show();
+
}
}
Index: mitk/Qmitk/CMakeLists.txt
===================================================================
--- mitk/Qmitk/CMakeLists.txt (Revision 15406)
+++ mitk/Qmitk/CMakeLists.txt (Arbeitskopie)
@@ -3,3 +3,4 @@
ELSE(MITK_BUILD_SHARED_CORE)
CREATE_QMITK()
ENDIF(MITK_BUILD_SHARED_CORE)
+TARGET_LINK_LIBRARIES(Qmitk qwt)

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
150
Default Alt Text
patch-1665 (26 KB)

Event Timeline

Patch (cannot be commited until qwt is open source)