17 #ifndef MITKGRABCUTOPENCVIMAGEFILTER_H
18 #define MITKGRABCUTOPENCVIMAGEFILTER_H
25 #include "itkObjectFactory.h"
26 #include "itkMutexLock.h"
32 template<
unsigned int T>
class Index;
35 class ConditionVariable;
68 itkFactorylessNewMacro(Self)
72 virtual ~GrabCutOpenCVImageFilter();
83 bool OnFilterImage(
cv::Mat& image ) override;
89 void SetModelPoints(ModelPointsList foregroundPoints);
96 void SetModelPoints(ModelPointsList foregroundPoints, ModelPointsList backgroundPoints);
101 void SetModelPoints(
cv::Mat foregroundMask);
108 void SetModelPoints(
cv::Mat foregroundMask,
cv::Mat backgroundMask);
122 void SetModelPointsDilationSize(
int modelPointsDilationSize);
135 void SetUseOnlyRegionAroundModelPoints(
unsigned int additionalBorder);
143 void SetUseFullImage();
151 cv::Rect GetRegionAroundModelPoints();
164 int GetResultImageId();
174 cv::Mat GetResultMask();
190 std::vector<ModelPointsList> GetResultContours();
209 ModelPointsList GetResultContourWithPixel(
itk::Index<2> pixelIndex);
216 cv::Mat GetMaskFromPointSets();
223 cv::Rect GetBoundingRectFromMask(
cv::Mat mask);
231 cv::Mat RunSegmentation(
cv::Mat input,
cv::Mat mask);
236 ModelPointsList ConvertMaskToModelPointsList(
cv::Mat mask);
238 int m_ModelPointsDilationSize;
240 bool m_UseOnlyRegionAroundModelPoints;
241 unsigned int m_AdditionalWidth;
242 cv::Rect m_BoundingBox;
244 ModelPointsList m_ForegroundPoints;
245 ModelPointsList m_BackgroundPoints;
247 cv::Mat m_InputImage;
248 cv::Mat m_GrabCutMask;
249 cv::Mat m_ResultMask;
251 unsigned int m_CurrentProcessImageNum;
268 static ITK_THREAD_RETURN_TYPE SegmentationWorker(
void* pInfoStruct);
275 itk::SmartPointer<
itk::MultiThreader> m_MultiThreader;
276 itk::SmartPointer<
itk::ConditionVariable> m_WorkerBarrier;
279 itk::SmartPointer<
itk::FastMutexLock> m_ImageMutex;
282 itk::SmartPointer<
itk::FastMutexLock> m_ResultMutex;
285 itk::SmartPointer<
itk::FastMutexLock> m_PointSetsMutex;
289 #endif // MITKGRABCUTOPENCVIMAGEFILTER_H
std::vector< itk::Index< 2 > > ModelPointsList
List holding image indices of the model points.
DataCollection - Class to facilitate loading/accessing structured data.
Makes the OpenCV GrabCut filter available as OpenCVImageFilter.
#define mitkClassMacro(className, SuperClassName)
Interface for image filters on OpenCV images.