
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Decrease Brightness of an Image in OpenCV Using C++
The way of decreasing brightness is very similar to increasing brightness. The only difference is subtracting the 'Scalar (B, G, R)' from the image. Here, we are subtracting the scalar value to decrease the brightness.
The following program shows how to decrease the brightness of an image in OpenCV.
Example
#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); }
Output
Advertisements