四、OpenCV调整图像的亮度

简介: 像素越靠近0图像越按,越靠近255,图像越亮,所以调整图片的亮度也就是调整每个像素点数值的大小。

四、OpenCV调整图像的亮度

      像素越靠近0图像越按,越靠近255,图像越亮,所以调整图片的亮度也就是调整每个像素点数值的大小。

原图

2345_image_file_copy_144.jpg

public class DemoMat {
    static{
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    }
    public static void main(String[] args) {
        Mat src=Imgcodecs.imread("aa.jpg");//读取图片
        src.convertTo(src,CvType.CV_32F);//转换格式
        System.out.println(src);
       float [] a=new float[3];
        for(int i=0;i<src.rows();i++){
            for (int j=0;j<src.cols();j++){
                src.get(i,j,a);//获取像素点
                a[0]=a[0]*(float)1.5+40;//每个通道的数值×1.5再加40
                a[1]=a[1]*(float)1.5+40;
                a[2]=a[2]*(float)1.5+40;
                src.put(i,j,a);//覆盖之前的数字
            }
        }
        src.convertTo(src,CvType.CV_8UC3);//准换格式,否则imshow()函数无法呈现
        HighGui.imshow("标题",src);
        HighGui.waitKey(0);
    }
}

执行结果

2345_image_file_copy_145.jpg


相关文章
|
12天前
|
算法 计算机视觉
【Qt&OpenCV 图像的感兴趣区域ROI】
【Qt&OpenCV 图像的感兴趣区域ROI】
15 1
|
12天前
|
运维 算法 计算机视觉
【Qt&OpenCV 图像的模板匹配 matchTemplate/minMaxLoc】
【Qt&OpenCV 图像的模板匹配 matchTemplate/minMaxLoc】
14 1
|
12天前
|
存储 编解码 算法
【Qt&OpenCV 检测图像中的线/圆/轮廓 HoughLinesP/HoughCircles/findContours&drawContours】
【Qt&OpenCV 检测图像中的线/圆/轮廓 HoughLinesP/HoughCircles/findContours&drawContours】
25 0
|
12天前
|
算法 计算机视觉
【Qt&OpenCV 图像边缘检测 Sobel/Laplace/Canny】
【Qt&OpenCV 图像边缘检测 Sobel/Laplace/Canny】
11 0
|
12天前
|
算法 计算机视觉
【Qt&OpenCV 图像的形态学变换 morpholgyEx】
【Qt&OpenCV 图像的形态学变换 morpholgyEx】
6 0
|
12天前
|
算法 计算机视觉
【Qt&OpenCV 图像阈值操作 threshold】
【Qt&OpenCV 图像阈值操作 threshold】
11 0
|
12天前
|
资源调度 算法 计算机视觉
【Qt&OpenCV 图像平滑/滤波处理 -- Blur/Gaussian/Median/Bilateral】
【Qt&OpenCV 图像平滑/滤波处理 -- Blur/Gaussian/Median/Bilateral】
15 0
|
12天前
|
算法 计算机视觉
【Qt&OpenCV 图像缩放resize()】
【Qt&OpenCV 图像缩放resize()】
10 0
|
17天前
|
算法 计算机视觉 Python
openCV 3计算机视觉 Python语言实现 笔记 第三章 使用OpenCV 3处理图像
openCV 3计算机视觉 Python语言实现 笔记 第三章 使用OpenCV 3处理图像
|
24天前
|
存储 编解码 API
【图像文本化】Base64编解码OpenCV4中 Mat 对象
【图像文本化】Base64编解码OpenCV4中 Mat 对象
18 0