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 2018 of 3366
188 Views
Suppose we have a two dimensional matrix A where each value is 0 or 1. Here a move consists of choosing any row or column, and toggling each value in that row or column: changing all 0s to 1s, and all 1s to 0s. Now after making any number of moves, every row of this matrix is interpreted as a binary number, and the score of the matrix is the sum of these numbers. So our task is to find the highest possible score. If the input is like −001110101100The output will be 39 as after toggling, the matrix will ... Read More
2K+ Views
Contours is nothing but the line joining all the points along the boundary of a particular shape. Using this you can −Find the shape of an object.Calculate the area of an object.Detect an object.Recognize an object.You can find the contours of various shapes, objects in an image using the findContours() method. In the same way you can drawYou can draw the found contours of an image using the drawContours() method this method accepts the following parameters −An empty Mat object to store the result image.A list object containing the contours found.An integer value specifying the contour to draw (-ve value ... Read More
3K+ Views
If you try to read an image using the OpenCV imread() method it returns a Mat object. If you want to display the contents of the resultant Mat object using an AWT/Swings window You need to convert the Mat object to an object of the class java.awt.image.BufferedImage. To do so, you need to follow the steps given below −Encode the Mat to MatOfByte − First of all, you need to convert the matrix to the matrix of a byte. You can do it using the method imencode() of the class Imgcodecs.This method accepts a String parameter(specifying the image format), a ... Read More
419 Views
You can compute the bitwise conjunction between two images using the bitwise_not() method of the org.opencv.core.Core class.This method accepts two Mat objects representing the source and destination matrices, calculates the inverse of each element in the source matrix and stores the result in the destination matrix.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; public class BitwiseNOTExample { public static void main(String args[]) throws Exception { //Loading the OpenCV core library System.loadLibrary( Core.NATIVE_LIBRARY_NAME ); //Reading the Image String file ="D://images//elephant.jpg"; Mat src = Imgcodecs.imread(file); ... Read More
9K+ Views
A digital image is stored as a 2D array of pixels and a pixel is the smallest element of a digital image.Each pixel contains the values of alpha, red, green, blue values and the value of each color lies between 0 to 255 which consumes 8 bits (2^8).The ARGB values are stored in 4 bytes of memory in the same order (right to left) with blue value at 0-7 bits, Green value at 8-15 bits, Red value at 16-23 bits and, alpha at 24-31 bits.Retrieving the pixel contents (ARGB values) of an image −To get the pixel values from an ... Read More
794 Views
You can draw makers on an image using the drawMarker() method of the org.opencv.imgproc.Imgproc class. This method accepts the following parameters −img − A Mat object representing the input image.position − An object of the class Point to specify the position of the marker.color − An object of the class Scalar to specify the color of the marker.markerType − An integer constant specifying the type of the marker.size − An integer value specifying the size of the marker.thickness − An integer value specifying the thickness of the marker.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; import ... Read More
1K+ Views
The detect() method of the org.opencv.features2d.Feature2D (abstract) class detects the key points of the given image. To this method, you need to pass a Mat object representing the source image and an empty MatOfKeyPoint object to hold the read key points.The drawMatches() method of the org.opencv.features2d.Feature2D class finds the matches between the key points of the two given images and draws them. This method accepts the following parameters −src1 − An object of the Mat class representing the first source image.keypoints1 − An object of the MatOfKeyPoint class representing the Key points of the first source image.src2 − An object of the ... Read More
1K+ Views
The detect() method of the org.opencv.features2d.Feature2D (abstract) class detects the key points of the given image. To this method, you need to pass a Mat the object representing the source image and an empty MatOfKeyPoint object to hold the read key points.You can draw the draw key points on the image using the drawKeypoints() method of the org.opencv.features2d.Features2d class.NoteSince Feature2D is an abstract class you need to instantiate one of its subclasses to invoke the detect() method. Here we have used the FastFeatureDetector class.Features2D and Features2d are two different classes of the package features2d don’t get confused...Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; ... Read More
923 Views
Contours are nothing but the line joining all the points along the boundary of a particular shape. Using this you can −Find the shape of an object.Calculate the area of an object.Detect an object.Recognize an object.You can find the contours of various shapes, objects in an image using the findContours() method. In the same way you can drawYou can also find the area of the shapes in the given input images. To do so you need to invoke the contourArea() method of the Imgproc class. This method accepts the contour of a particular shape, finds and returns its area.ExampleFollowing java ... Read More
2K+ Views
Contours are nothing but the line joining all the points along the boundary of a particular shape. Using this you can −Find the shape of an object.Calculate the area of an object.Detect an object.Recognize an object.You can find the contours of various shapes, objects in an image using the findContours() method. This method accepts the following parameters −A binary image.An empty list object of type MatOfPoint to store the contours.An empty Mat object to store the image topology.Two integer variables to specify the mode and method to find the contours of the given image.Exampleimport java.util.ArrayList; import java.util.Iterator; import java.util.List; import ... Read More