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
Programming Articles - Page 1349 of 3366
731 Views
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
1K+ Views
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
465 Views
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
2K+ Views
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
318 Views
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
563 Views
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
5K+ Views
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
487 Views
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
3K+ Views
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
5K+ Views
In OpenCV, we can put some text in the image by using puttext() function. This function is defined in header. To put text in an image, we first need to declare the matrix which will load the image.Instead of loading an image in our program, we have filled matrix with white color, and then we put the text in that matrix. We need to define the text's starting point in the matrix, the text's font, the font's color and the font's weight.The basic syntax of this method is as follows −SyntaxputText(image, "Text in Images", text_position, FONT_HERSHEY_COMPLEX, font_size, font_Color, font_weight);The ... Read More