如何使用的ConvertTo来增强对比度? [英] How to enhance the contrast using convertTo?

查看:439
本文介绍了如何使用的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆