如何使用 C++ 在 OpenCV 中降低影像的亮度?
降低亮度的做法與提高亮度非常相似。唯一不同的是從影像中減去“標量 (B, G, R)”。這裡,我們減去標量值來降低亮度。
以下是使用 OpenCV 降低影像亮度的程式。
示例
#include<iostream>
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main() {
Mat original; //Declaring a matrix to load the original image//
Mat dimmer;//Declaring a matrix to load the image after changing the brightness//
namedWindow("Original");//Declaring window to show the original image//
namedWindow("Dimmer");//Declaring window to show the brighter image//
original = imread("bright.jpg");
dimmer = original - Scalar(80, 80, 80);//subtracting integer value to change the brightness//
imshow("Original", original);//showing original image//
imshow("Dimmer", dimmer);//showing brighter image//
waitKey(0);//wait for keystroke//
return(0);
}輸出

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP