Hi Stefan,
There is another way to extract image statistics of a ROI on an mitk::Image which may be helpful. The class mitk::ImageStatisticsCalculator has as input a grayscale mitk::Image and a mask, which can be either another (binary) mitk::Image or an mitk::PlanarFigure. PlanarFigures are simple representations of measurements in the 2D plane, such as lines, circles, polygons, etc. (see doxygen documentation for sub-classes). After initializing the ImageStatisticsCalculator with an image and a mask, you can calculate the histogram and a set of basic statistics information by calling ComputeStatistics( t ), with t being the time point you are interested in. The histogram and statistics can then be retrieved with the provided get methods. Note that this code is currently only available in the MITK SVN checkout, but will also be available in the next public release of MITK. To see an example of how to use the code, download MITK SVN, and compile it with Measurement and ImageStatistics bundles activated. The Measurement bundle allows you to define PlanarFigures on an image, while the ImageStatistics bundle displays statistics and a histogram of the image or the mask (whatever is selected in the data storage). (To make this work on time-resolved images, you have to uncomment some code in QmitkMeasurement::PlanarFigureSelectionChanged(), which prevents the usage in 4D images because PlanarFigures currently do not have time resolution, i.e., they are constant over time, which should not be a problem for you I suppose...) Regards, Mathias -----Original Message----- From: Zelzer Sascha [mailto:[email protected]] Sent: Friday, March 26, 2010 7:57 PM To: Stefan Galowicz; [email protected] Subject: Re: [mitk-users] Calculating greyscale value of ROIs per frame Hi Stefan, maybe http://docs.mitk.org/nightly-qt4/classmitk_1_1MaskImageFilter.html is the filter you are looking for? You set your original image as input and your segmentation as mask image. You could then use the output image to iterate over the pixels and calculate the mean, or look up a proper ITK class or maybe use mitk::Image::GetScalarHistogram(). Hope this helps, Sascha ________________________________________ From: Stefan Galowicz [[email protected]] Sent: Wednesday, March 24, 2010 8:41 PM To: [email protected] Subject: [mitk-users] Calculating greyscale value of ROIs per frame Hello dear list, I recently attended the presentation of MITK in Aachen and am now trying to write my first MITK plugin. :) The plugin is supposed to plot the average greyscale value of selected regions in an animated image (ultrasonic scan) using ExtApp. But how do I actually access the ROIs? I tried to find something useful in the documentation, but ended up confused. The only "documentation" I could find showed the implementation of methods of classes which had the world "Slice" in them. Can someone point me into the right direction how to read the pixel values out of ROIs per frame in an animation? Thanks a lot for your help in advance! Stefan P.S.: I'm currently attempting this: void QmitkContrastAnalyzerMITKPluginView :: OnSelectionChanged(std::vector<mitk::DataNode*> nodes) { greyscaleData.clear(); // std::vector<float>, compute greyscale value from 0.0 to 1.0 for ROI in each frame /* // dummy data for plotting, works. how to replace this with real data? greyscaleData.reserve(10); for(unsigned i = 0; i < greyscaleData.capacity(); ++i) greyscaleData.push_back(static_cast<float>(i) / greyscaleData.capacity()); */ // here i'm attempting to find a node with segmentation data for(std::vector<mitk::DataNode*>::const_iterator node = nodes.begin(); node != nodes.end(); ++node) { MITK_INFO << "stefan: parsing " << (*node)->GetName(); if(!*node) { MITK_INFO << "stefan: not a node"; continue; } const mitk::BaseData* data = (*node)->GetData(); if(!data) { MITK_INFO << "stefan: no data in node"; continue; } bool isSegmentation = false; (*node)->GetBoolProperty("segmentation", isSegmentation); if(!isSegmentation) { MITK_INFO << "stefan: no segmentation data in node"; continue; } mitk::Image* segmentationImage = dynamic_cast<mitk::Image*>((*node)->GetData()); if(!segmentationImage) { MITK_INFO << "stefan: segmentation data cast to image failed"; continue; } MITK_INFO << "stefan: prospecting " << segmentationImage->GetDimension() << "D segmentation " << (*node)->GetName(); /********** now how to get the pixel values out of the ROIS? *******/ } // tells the graph plotting widget which data to plot graphWidget->setData(greyscaleData); } An example DICOM image shows this information in ExtApp: Image (0xaa4f628) PixelType: s BitsPerElement: 16 NumberOfComponents: 1 BitsPerComponent: 16 Dimension: 3 Dimensions: 800 600 381 TimeSlicedGeometry: TimeSlicedGeometry (0xaa3bfa0) EvenlyTimed: 1 TimeSteps: 1 GetGeometry3D(0): SlicedGeometry3D (0xaa5c370) IndexToWorldTransform: Matrix: 1 0 0 0 1 0 0 0 1 Offset: [0, 0, 0] Center: [0, 0, 0] Translation: [0, 0, 0] Inverse: 1 0 0 0 1 0 0 0 1 Scale : 1 1 1 BoundingBox: ( 0,800 0,600 0,381 ) Origin: [0, 0, 0] ImageGeometry: 1 Spacing: [1, 1, 1] TimeBounds: [-3.40282e+38, 3.40282e+38] EvenlySpaced: 1 DirectionVector: [0, 0, 1] Slices: 381 GetGeometry2D(0): PlaneGeometry (0xaa3b2c0) IndexToWorldTransform: Matrix: 1 0 0 0 1 0 0 0 1 Offset: [0, 0, 0] Center: [0, 0, 0] Translation: [0, 0, 0] Inverse: 1 0 0 0 1 0 0 0 1 Scale : 1 1 1 BoundingBox: ( 0,800 0,600 0,1 ) Origin: [0, 0, 0] ImageGeometry: 1 Spacing: [1, 1, 1] TimeBounds: [-3.40282e+38, 3.40282e+38] ScaleFactorMMPerUnitX: 1 ScaleFactorMMPerUnitY: 1 Normal: [0, 0, 1] ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ mitk-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mitk-users ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ mitk-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mitk-users ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ mitk-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mitk-users
