✨博客主页:王乐予🎈
✨年轻人要:Living for the moment(活在当下)!💪
🏆推荐专栏:【图像处理】【千锤百炼Python】【深度学习】【排序算法

话不多说,直接看代码!

import cv2
import os
import numpy as np

def read_path(file_pathname):
    for filename in os.listdir(file_pathname):
        print(filename)
        img = cv2.imread(file_pathname+'/'+filename)
        image = np.power(img, 0.8)			# 对像素值指数变换
        cv2.imwrite(r"C:\Users\Lenovo\Desktop\change" + "/" + filename, image)
read_path(r"C:\Users\Lenovo\Desktop\original")

这里使用np.power()指数变换函数对图像像素值进行处理,参数设置方式如下:

  • 小于1:降低图像亮度
  • 大于1:提高图像亮度

图片展示如下:
在这里插入图片描述
在这里插入图片描述在这里插入图片描述

GitHub 加速计划 / opencv31 / opencv
216
19
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:14 天前 )
3c3a26b6 imgcodecs: bmp: relax decoding size limit to over 1GiB #27811 Close https://github.com/opencv/opencv/issues/27789 Close https://github.com/opencv/opencv/issues/23233 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake 1 小时前
744d5ecd libtiff upgrade to version 4.7.1 #27806 close https://github.com/opencv/opencv/issues/27784 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake 2 小时前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐