- 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
Found 184 Articles for OpenCV
563 Views
To draw an ellipse, we need a center, major axis and minor axis. That means we need three parameters for the ellipse. We need a matrix where we will draw the ellipse, and we need to declare line thickness and line color.When we want to draw an ellipse using OpenCV, we have to mention the angle of rotation, and there are two additional parameter starting point and ending point. To call 'ellipse()' function, we need to include header file.The basic syntax of this method is as follows −Syntaxellipse(whiteMatrix, center, xy, angle, starting_point, ending_point, line_Color, thickness);The following program shows how to ... Read More
6K+ Views
A circle has a center and a radius. To draw a circle using OpenCV, we have to define the center and the radius. In OpenCV we have to include header because 'circle()' function is defined in this header.The basic syntax of this method is as follows −Syntaxcircle(whiteMatrix, center, radius, line_Color, thickness);The following program represents how to draw a circle in OpenCV.Example#include #include #include using namespace cv; using namespace std; int main() { Mat whiteMatrix(200, 200, CV_8UC3, Scalar(255, 255, 255));//Declaring a white matrix Point center(100, 100);//Declaring the center point int radius = 50; //Declaring the radius ... Read More
1K+ Views
To draw a line we need two points-the starting point and ending point. We also require a canvas to draw the line.Using OpenCV, the matrix in our canvas, we need to define the line's starting and ending points. We require to assign a color to the line as well. The thickness of the line has to be explained too. If we want to draw a line using OpenCV, we need to declare a matrix, two points, and color and line thickness.Using OpenCV we have to include header because line() function is defined in this header.The basic syntax of this ... Read More
1K+ Views
Digital images are made of pixels. Using OpenCV, it is easy to read the value of pixels. However, if we want to get the pixel values, we have to handle a single channel separately.Here we are loading an image in the matrix named 'cimage', and then it converts the image using 'cvtColor(cimage, img, COLOR_BGR2GRAY); ' and store it in the matrix named 'img'.The following program read the pixel value of an image and shows the values in console window.Example#include #include #include using namespace std; using namespace cv; int main() { int x;//Declaring an integer variable to hold values of pixels// ... Read More
4K+ Views
Inverting a binary image means inverting the pixel values. From a visual perspective, when we invert a binary image, white pixels will be converted to black, and black pixels will be converted to white.The basic form of this function is −cvtColor(original_image, grayscale_image, COLOR_BGR2GRAY);The next line is converting the grayscale image into a binary image and storing the converted image into 'binary_image' matrix.threshold(grayscale_image, binary_image, 100, 255, THRESH_BINARY);Here 'grayscale_image' is the source matrix, 'binary_image' is the destination matrix. After that, there are two values 100 and 255. These two values represent the threshold range. In this line, the threshold range represents the ... Read More
2K+ Views
A binary image is just a digital image that represents two colors, black and white. From an image processing perspective, a binary image contains pixels with two possible values- zero and one. When the value of a pixel is 0, it represents a pure black color. When the value of the pixel is 1, it means pure white color.In a grayscale image, there are 256 different possible values for each. But in Binary Image, there are only two possible values. Binary images have different types of applications. For example, morphological transformation requires a binary image, object shape extraction from background ... Read More
1K+ Views
Color space is the model of representing colors. There are different ways of describing colors. For example, RGB, CYMK, HSV, Grayscale etc.Here, we used a new header named 'imgproc.hpp'. This 'imgproc.hpp' is the abbreviation of Image Processing. To convert color spaces, we need to use 'cvtColor()' function of OpenCV. This function is defined in 'imgproc' header file. That's why we have included 'imgproc.hpp'.Firstly, we declared two matrices and two windows. These are for loading and showing the images. Then we loaded our image named 'cat.jpg' into 'myImage' matrix. After that we used 'cvtColor(myImage, myImage_Converted, COLOR_RGB2GRAY)'. This line converts the RGB color space ... Read More
4K+ Views
There are three channels in an RGB image- red, green and blue. The color space where red, green and blue channels represent images is called RGB color space. In OpenCV, BGR sequence is used instead of RGB. This means the first channel is blue, the second channel is green, and the third channel is red. To split an RGB image into different channels, we need to define a matrix of 3 channels. We use 'Mat different_Channels[3]' to define a three-channel matrix.Next, we split the loaded image using OpenCV 'split()' function. The format of this function is 'split(Source Matrix, Destination Matrix)'. This function ... Read More
1K+ Views
In this topic, we will understand how to find out the number of channels of an image. After running the program, the number of the channel will be shown in the console window.To get the number of the channel, we have used a class of OpenCV named 'channels()'. When we pass the image matrix as an object of the class 'channels()', it gives the channel an integer value.The following program counts the number of the channels and show it in the console window.Example#include #include using namespace std; using namespace cv; int main(int argc, char** argv) { Mat image_load;//Declaring a ... Read More
638 Views
An array is a convenient method to store and retrieve the collection of data. In OpenCV, we can use this concept to load multiple images in an image array and show them using the array's index number.The following program loads multiple images in a matrix array and shows the array's images called by the index number.Example#include #include using namespace cv; using namespace std; int main(int argc, const char** argv) { Mat myImage_array[3];//declaring a matrix named myImage// namedWindow("PhotoFrame1");//declaring the window to show the image// namedWindow("PhotoFrame2");//declaring the window to show the image// namedWindow("PhotoFrame3");//declaring the window to show the ... Read More