- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to decrease the 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
- Related Articles
- JavaFX example to decrease the brightness of an image using OpenCV.
- How to change the brightness of an image in OpenCV using C++?
- How to alter the brightness of an image using Java OpenCV library?
- How to change the contrast and brightness of an image using OpenCV in Python?
- Altering the brightness and contrast of an image using JavaFX and OpenCV
- How to adjust the brightness of an image in PyTorch?
- How to save an Image in OpenCV using C++?
- How to rotate an image in OpenCV using C++?
- How to resize an image in OpenCV using Python?
- How to extract the foreground of an image using OpenCV Python?
- Setting the Image Brightness using CSS3
- How to compute the morphological gradient of an image using OpenCV in Python?
- How to compute the extent of an object in image using OpenCV Python?
- How to alter the contrast of an image using Java OpenCV library?
- How to alter the sharpness of an image using Java OpenCV library?

Advertisements