The histogram of an image shows the frequency of pixels' intensity values. In an image histogram, the X-axis shows the gray level intensities and the Y-axis shows the frequency of these intensities.Histogram equalization improves the contrast of an image, in order to stretch out the intensty range. You can equalize the histogram of a given image using the equalizeHist() function.The basic syntax of this function is −SyntaxequalizeHist(Source Matrix, Destination Matrix).In this program, it equalizes a grayscale image. It means that there is only one channel. This function equalized the pixel value of that single channel. However, when we apply this ... Read More
The histogram represents the depth intensity of an image. For example, consider an image with a color depth of 8 bit. It means every pixel can have color depth from 0 to Means from 0 to 255. If the image is an RGB image, it has a red, green, and blue channel. For example, at the point of the image, there is only red. Then the color depth of that image is in the red channel, and the value of the pixel will vary from 0 to 255. 0 means no red and 255 means more read.The histogram shows this ... Read More
Changing brightness and contrast are frequent editing effect in image processing.Here, we will learn how to change the contrast of images. Contrast controls the sharpness of the image. Higher the contrast the sharper the image, lower the contrast the smother the image.Changing the contrast means increasing the weight of the pixels. More the contrast, sharper the image is. To change the contrast, multiply the pixel values with some constant. For example, if multiply all the pixel values of an image by 2, then the pixel's value will be doubled, and the image will look sharper.The following program demonstrates how to ... Read More
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 #include 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 ... Read More
Changing the brightness means changing the value of pixels. It means adding or subtracting value some integer value with the current value of each pixel. When you add some integer value with every pixel, it means you are making the image brighter. When you subtract some constant value from all of the pixels, you are reducing the brightness. First, we will learn how to increase the brightness and second we will learn how to reduce the brightness.Increasing the BrightnessIncreasing the Brightness using OpenCV is very easy. To increase the brightness, add some additional values with each channel, and the brightness ... Read More
OpenCV has C++ STL compatible 'Mat iterator' class. Using this 'Mat iterator' class, we can access pixels very easily. We have to create an object of 'Mat iterator' class. We can do it as 'Mat_: : iterator example'. We have to use an underscore after 'Mat' like 'Mat_' because it is a template method. In this method, the return type must be specified while creating an object of 'iterator' class. That is why we have declared the datatype .The following program demonstrates how to reduce the color using Iterator Method in OpenCV.Example#include #include using namespace std;//Declaring std namespace using namespace ... Read More
In image processing, we perform computation on the image. To be more specific, we perform a calculation on pixel so the higher the number of pixels, the more the time consuming the computation becomes. To reduce the computation time, we require to scan the image efficiently. We will learn how to implement an efficient image scanning loop using pointers.Here we will see the pixel scanning process with an example of the color reduction strategy. Color images such as RGB images are composed of 3 channels. Each of these channels has the same number of pixels but with corresponding values. Each ... Read More
To read the value of a specific pixel, we can use either 'at' or 'direct access' method. Here, we will learn both of the approaches.Let's start with 'at' method. The following program reads the pixel value located at (10, 29) of an RGB image.Example#include #include using namespace std; using namespace cv; int main() { Mat image;//taking an image matrix// image = imread("sky.jpg");//loading an image// int x = image.at(10, 29)[0];//getting the pixel values// int y = image.at(10, 29)[1];//getting the pixel values// int z = image.at(10, 29)[2];//getting the pixel values// cout
In the previous method (the 'at' method), we need to specify the image type while accessing the pixel values. There is another method which is simpler than 'at' method. It is called direct access method. To access pixel value using this method, we need to specify the Mat type such as Mat, Mat, Mat and so on.The following program demonstrates how to change Pixel Values using Direct Access Method in OpenCV.Example#include #include using namespace cv;//Declaring cv namespace using namespace std; void direct_access(Mat_ &image, int n){ //Declaring the function// for (int x = 0; x < n; x++){ //initiating a ... Read More
In a grayscale image, the pixel value is a single numeric value. But in a color image such as RGB image, the pixel is a vector having three values. These three values represent three channels.Here we will create a function that accesses both the grayscale image and RGB image pixel values and randomly adds noise to image pixels. Then we call the function inside the main() function to observe the result.The following program demonstrates how to change Pixel Values using 'at' method in OpenCV.Example#include #include using namespace cv;//Declaring cv namespace using namespace std; void adding_Noise(Mat& image, int n){ //'adding_Noise' function// ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP