MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkConvertGrayscaleOpenCVImageFilter.cpp
Go to the documentation of this file.
1
/*============================================================================
2
3
The Medical Imaging Interaction Toolkit (MITK)
4
5
Copyright (c) German Cancer Research Center (DKFZ)
6
All rights reserved.
7
8
Use of this source code is governed by a 3-clause BSD license that can be
9
found in the LICENSE file.
10
11
============================================================================*/
12
13
#include "
mitkConvertGrayscaleOpenCVImageFilter.h
"
14
15
#include <opencv2/imgproc.hpp>
16
#include <opencv2/imgproc/types_c.h>
17
18
namespace
mitk
{
19
20
bool
ConvertGrayscaleOpenCVImageFilter::OnFilterImage
( cv::Mat& image )
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
mitk::ConvertGrayscaleOpenCVImageFilter::OnFilterImage
bool OnFilterImage(cv::Mat &image) override
Converts given image to grayscale.
Definition
mitkConvertGrayscaleOpenCVImageFilter.cpp:20
mitkConvertGrayscaleOpenCVImageFilter.h
mitk
IGT Exceptions.
Definition
mitkAlgorithm.h:16
Modules
OpenCVVideoSupport
Commands
mitkConvertGrayscaleOpenCVImageFilter.cpp
Generated by
1.12.0