Maruthi Krishna

Maruthi Krishna

500 Articles Published

Articles by Maruthi Krishna

Page 30 of 50

How to create custom color maps in Java using OpenCV?

Maruthi Krishna
Maruthi Krishna
Updated on 09-Apr-2020 471 Views

The applyColorMap() method of the Imgproc class applies specified color map to the given image. This method accepts three parameters −Two Mat objects representing the source and destination images.An integer variable representing the type of the color map to be applied.You can pass any of the following as color map value to this method.COLORMAP_AUTUMN, COLORMAP_BONE, COLORMAP_COOL, COLORMAP_HOT, COLORMAP_HSV, COLORMAP_JET, COLORMAP_OCEAN , COLORMAP_PARULA, COLORMAP_PINK, COLORMAP_RAINBOW, COLORMAP_SPRING, COLORMAP_SUMMER, COLORMAP_WINTER.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class CustomColorMaps {    public static void main(String args[]) {       // Loading the OpenCV core library       System.loadLibrary(Core.NATIVE_LIBRARY_NAME);     ...

Read More

How to alter the brightness of a grey scale image?

Maruthi Krishna
Maruthi Krishna
Updated on 09-Apr-2020 325 Views

The equalizeHist() method of the Imgproc class accepts a greyscale image and equalizes its histogram, which will, in turn, normalizes the brightness and increases the contrast of the given image. This method accepts two parameters −A Mat object representing the source image (greyscale).A Mat object to save the result.ExampleFollowing Java program reads a colored image as greyscale, saves it, normalizes the brightness and increases the contrast of the given image and saves it.import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class HstExample {    public static void main(String args[]) {       //Loading the OpenCV core ...

Read More

How to add noise to an image using Java OpenCV library?

Maruthi Krishna
Maruthi Krishna
Updated on 09-Apr-2020 761 Views

To add noise to a given image using OpenCV −Read the contents of the given image to a Mat object.Create two more empty matrices to store the noise and the resultant matrices.Create two MatOfDouble matrices to store mean and standard deviation.Get the mean and standard deviation values using the meanStdDev() method.Create a matrix with random elements (to store the noise) using the randn() method.To this method pass the above-created source, mean and standard deviation objects.Finally, add the noise matrix and source matrix and save as destination.Exampleimport java.awt.Image; import java.awt.image.BufferedImage; import java.io.IOException; import javafx.application.Application; import javafx.embed.swing.SwingFXUtils; import javafx.scene.Group; import javafx.scene.Scene; import ...

Read More

How to draw an ellipse in OpenCV using Java?

Maruthi Krishna
Maruthi Krishna
Updated on 09-Apr-2020 402 Views

The org.opencv.imgproc package of Java OpenCV library contains a class named Imgproc. To draw an ellipse you need to invoke the ellipse() method of this class. This method accepts the following parameters −A Mat object representing the image on which the ellipse is to be drawn.A RotatedRect object (The ellipse is drawn inscribed in this rectangle.)A Scalar object representing the color of the Rectangle(BGR).An integer representing the thickness of the Rectangle(default:1).Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.Point; import org.opencv.core.RotatedRect; import org.opencv.core.Scalar; import org.opencv.core.Size; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class DrawingEllipse {    public static void main(String args[]) {   ...

Read More

How to convert colored image to HLS using Java OpenCV library?

Maruthi Krishna
Maruthi Krishna
Updated on 09-Apr-2020 260 Views

You can convert HLS image to RGB (colored) image by passing Imgproc.COLOR_RGB2HLS as the 3rd parameter to the cvtColor() method.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class HSL2RGB {    public static void main(String args[]) throws Exception {       System.loadLibrary( Core.NATIVE_LIBRARY_NAME );       Mat src = Imgcodecs.imread("D:\images\car3.jpg");       Mat dst = new Mat();       Imgproc.cvtColor(src, dst, Imgproc.COLOR_RGB2HLS);       Imgcodecs imageCodecs = new Imgcodecs();       imageCodecs.imwrite("D:\images\hslImage.jpg", dst);       System.out.println("Image Saved");    } }InputOutput

Read More

How to convert HLS to colored image using Java OpenCV library?

Maruthi Krishna
Maruthi Krishna
Updated on 09-Apr-2020 284 Views

The cvtColor() method of the Imgproc class changes/converts the color of the image from one to another. This method accepts three parameters −src − A Matrix object representing source.dst − A Matrix object representing the destination.code − An integer value representing the color of the destination image.You can convert a colored image to an HLS image by passing Imgproc.COLOR_RGB2HLS as a parameter to the above method.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class RGB2HSL {    public static void main(String args[]) throws Exception {       //Loading the OpenCV core library       System.loadLibrary( Core.NATIVE_LIBRARY_NAME ); ...

Read More

How to convert HSV to colored image using Java OpenCV library?

Maruthi Krishna
Maruthi Krishna
Updated on 09-Apr-2020 390 Views

The cvtColor() method of the Imgproc class changes/converts the color of the image from one to another. This method accepts three parameters −src − A Matrix object representing source.dst − A Matrix object representing the destination.code − An integer value representing the color of the destination image.To convert an HSV image to RGB you need to pass Imgproc.COLOR_HSV2RGB as the third parameter to this method.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class HSV2RGB {    public static void main(String args[]) throws Exception {       //Loading the OpenCV core library       System.loadLibrary( Core.NATIVE_LIBRARY_NAME );     ...

Read More

How to convert RGB image to HSV using Java OpenCV library?

Maruthi Krishna
Maruthi Krishna
Updated on 09-Apr-2020 1K+ Views

The cvtColor() method of the Imgproc class changes/converts the color of the image from one to another. This method accepts three parameters −src − A Matrix object representing source.dst − A Matrix object representing the destination.code − An integer value representing the color of the destination image.To convert an RGB image to HSV you need to pass Imgproc.COLOR_RGB2HSV as the third parameter to this method.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class RGB2HSV {    public static void main(String args[]) throws Exception {       //Loading the OpenCV core library       System.loadLibrary( Core.NATIVE_LIBRARY_NAME );   ...

Read More

Altering the brightness and contrast of an image using JavaFX and OpenCV

Maruthi Krishna
Maruthi Krishna
Updated on 09-Apr-2020 733 Views

The convertTo() method of the org.opencv.core.Mat class accepts 4 parameters namely: mat(empty matrix), rtype(integer), alpha(integer), beta(integer), in the same order.To increase the brightness − You need to reduce the beta value from 0 towards -255(keeping alpha value 1).To decrease the brightness − You need to increase the beta value from 0 towards 255(keeping alpha value 1).To increase the contrast − You need to increase the alpha value from 1 towards 100(keeping beta value 0).To decrease the contrast − You need to decrease the alpha value from 1 to 0 (keeping beta value 0).ExampleFollowing is a JavaFX program with two slide ...

Read More

How to alter the sharpness of an image using Java OpenCV library?

Maruthi Krishna
Maruthi Krishna
Updated on 09-Apr-2020 2K+ Views

Sharpening an image is the opposite of blur. To alter the sharpness of an image using the OpenCV library, you need to smooth/blur it using the Gaussian filter and subtract the smoothed version from the original image.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.Size; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class AlteringSharpness {    public static void main (String[] args) {       //Loading the OpenCV core library       System.loadLibrary( Core.NATIVE_LIBRARY_NAME );       //Reading the Image from the file       String file ="D:\Image\lamma1.jpg";       Mat src = Imgcodecs.imread(file, Imgcodecs.IMREAD_COLOR);       //Creating an ...

Read More
Showing 291–300 of 500 articles
« Prev 1 28 29 30 31 32 50 Next »
Advertisements