MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkConvertGrayscaleOpenCVImageFilter.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
14
15#include <opencv2/imgproc.hpp>
16#include <opencv2/imgproc/types_c.h>
17
18namespace mitk {
19
21{
22 // there is nothing to do if the image is grayscale already
23 if (image.channels() == 1) { return true; }
24
25 cv::Mat buffer;
26
27 cv::cvtColor(image, buffer, CV_RGB2GRAY, 1);
28
29 // content of buffer should now be the content of image
30 buffer.copyTo(image);
31
32 return true;
33}
34} // namespace mitk
bool OnFilterImage(cv::Mat &image) override
Converts given image to grayscale.
IGT Exceptions.