如何使用的ConvertTo来增强对比度? [英] How to enhance the contrast using convertTo?
问题描述
我在OpenCV的c语言新。我需要提升哟我的图像对比度。我使用的功能
I am new in opencv c language. I need yo enhance my image contrast. i used the function
cvconvertTo(imh,-1,2,0);
问题是我应该使用输入图像变量?
请帮帮我
谢谢
The problem is where should i use the input image variable? Please help me Thank you
推荐答案
在OpenCV的教程看一看<一个href=\"http://docs.opencv.org/2.4/doc/tutorials/core/basic_linear_transform/basic_linear_transform.html\"相对=nofollow>更改图像的对比度和亮度。
Take a look at the OpenCV tutorial Changing the contrast and brightness of an image.
由于您的参数字母
(比例的)和测试版
(移的),你可以应用转换:
Given you parameters alpha
(scale) and beta
(shift), you can apply the transformation:
给定输入图像:
您可以更改对比度和亮度来获得,例如,这样的:
you can change the contrast and brightness to get, for example, this:
您可以做到这一点的 C ++ API (推荐):
You can do this with C++ api (recommended):
#include <opencv2\opencv.hpp>
using namespace cv;
int main()
{
Mat3b img = imread("path_to_image");
imshow("Before", img);
double alpha = 2;
double beta = 10;
img.convertTo(img, -1, alpha, beta);
imshow("After", img);
waitKey();
return 0;
}
您也可以使用过时C API
#include <opencv2\opencv.hpp>
using namespace cv;
int main()
{
IplImage* img = cvLoadImage("path_to_image");
cvShowImage("Before", img);
double alpha = 2;
double beta = 10;
cvConvertScale(img, img, alpha, beta);
cvShowImage("After", img);
cvWaitKey();
return 0;
}
这篇关于如何使用的ConvertTo来增强对比度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!