Found 2616 Articles for Java

Java Image Translation example using OpenCV.

Maruthi Krishna
Updated on 09-Apr-2020 09:02:08

319 Views

The warpAffine() method of the Imgproc class applies an affine transformation to the specified image. This method accepts −Three Mat objects representing the source, destination, and transformation matrices.An integer value representing the size of the output image.To translate an image Create a translation matrix and pass it as a transformation matrix to this method along with the other parameters.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 javafx.scene.image.ImageView; import javafx.scene.image.WritableImage; import javafx.stage.Stage; import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.MatOfPoint2f; import org.opencv.core.Point; import org.opencv.core.Size; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class TranslatingAnImage extends Application { ... Read More

How to rotate an image with OpenCV using Java?

Maruthi Krishna
Updated on 09-Apr-2020 08:58:54

481 Views

The warpAffine() method of the Imgproc class applies an affine transformation to the specified image. This method accepts −Three Mat objects representing the source, destination, and transformation matrices.An integer value representing the size of the output image.To rotate an image Create a rotation matrix and pass it as a transformation matrix to this method along with the other parameters.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 javafx.scene.image.ImageView; import javafx.scene.image.WritableImage; import javafx.stage.Stage; import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.Point; import org.opencv.core.Size; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class RotatingAnImage extends Application {    public ... Read More

Image processing/OpenCV image dilation Java Example.

Maruthi Krishna
Updated on 09-Apr-2020 08:55:48

778 Views

Erosion and dilation are the two basic morphological operations. As the name implies, morphological operations are the set of operations that process images according to their shapes.During dilation operation additional pixels are added to an image boundary, a total number of pixels added during the dilation process depends on the dimensions of the structuring element used.You can dilate an image using the dilate() method of the Imgproc class, this method three mat objects representing source, destination, and kernel.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 javafx.scene.image.ImageView; import javafx.scene.image.WritableImage; import javafx.stage.Stage; import org.opencv.core.Core; import ... Read More

Image processing/OpenCV image erosion Java Example.

Maruthi Krishna
Updated on 09-Apr-2020 08:52:53

698 Views

Erosion and dilation are the two basic morphological operations. As the name implies, morphological operations are the set of operations that process images according to their shapes.During erosion operation, additional pixels are removed from image boundaries, total number of pixels removed during the erosion process depends on the dimensions of the structuring element used.You can perform erosion operation on an image using the erode() method of the Imgproc class, this method three mat objects representing source, destination, and kernel.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 javafx.scene.image.ImageView; import javafx.scene.image.WritableImage; import javafx.stage.Stage; import org.opencv.core.Core; ... Read More

How to implement Median blur in OpenCV using Java?

Maruthi Krishna
Updated on 09-Apr-2020 08:49:06

417 Views

You can blur an image by filtering it using a low-pass filter, this removes high frequency content (noise, edges) from an image.Median Blurring is one of the blurring techniques provided by OpenCV, it is highly efficient in removing salt and pepper noise of an image. This replaces the central element with the median of all the pixels in the kernel area.You can filter/blur an image by this technique using the medianBlur() method, this method acceptsTwo Mat objects representing the source and destination images.A Size object representing the size of the kernel.Exampleimport java.awt.Image; import java.awt.image.BufferedImage; import java.io.IOException; import org.opencv.core.Core; import org.opencv.core.Mat; ... Read More

How to perform Bitwise XOR operation on two images using Java OpenCV?

Maruthi Krishna
Updated on 09-Apr-2020 08:46:00

345 Views

You can compute bitwise exclusive or between two images using the bitwise_xor() method of the org.opencv.core.Core class.This method accepts three Mat objects representing the source, destination, and result matrices, calculates the bitwise exclusive or of each element in the source matrices and stores the result in the destination matrix.ExampleIn the following Java example, we are converting an image into binary and gray scale and calculating the bitwise exclusive or of the results.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 BitwiseXORExample {    public static void main(String args[]) throws Exception {       //Loading the OpenCV core ... Read More

How to implement Bilateral blur in OpenCV using Java?

Maruthi Krishna
Updated on 09-Apr-2020 08:42:11

263 Views

You can blur an image by filtering it using a low-pass filter, this removes high frequency content (noise, edges) from an image. Bilateral Filtering is one of the blurring techniques provided by OpenCV, it −removes noise efficientlykeeps the edges sharpComparatively slowYou can apply the bilateral filter on an image using the bilateralFilter() method, this method acceptsTwo Mat objects representing the source and destination images.An integer representing the diameter of the pixel neighborhood.Two integer variables of the type integer representing the filter sigma in the color space and coordinate space.An Integer object representing the type of the border used.Exampleimport java.awt.Image; import ... Read More

How to implement Gaussian blur in OpenCV using Java?

Maruthi Krishna
Updated on 09-Apr-2020 08:38:49

1K+ Views

You can blur an image by filtering it using a low-pass filter, this removes high frequency content (noise, edges) from an image.Gaussian Blurring is one of the blurring techniques provided by OpenCV, it is highly efficient in removing the noise of an image. This replaces the central element with the average of all the pixels in the kernel area.You can filter/blur an image by this technique using the GaussianBlur() method, this method accepts −Two Mat objects representing the source and destination images.A Size object representing the size of the kernel.A variable of the type double representing the Gaussian kernel standard ... Read More

How to implement blur (averaging) in OpenCV using Java?

Maruthi Krishna
Updated on 09-Apr-2020 08:35:45

205 Views

You can blur an image by filtering it using a low-pass filter, this removes high frequency content (noise, edges) from an image.Averaging is one of the blurring techniques provided by OpenCV, this replaces the central element with the average of all the pixels in the kernel areaYou can filter/blur an image by this technique using the blur() or, boxFilter() methods, the blur() method accepts −Two Mat objects representing the source and destination images.A Size object representing the size of the kernel.An integer variable representing the anchor point.An integer variable of representing the type of the border to be used to ... Read More

How to draw a circle in OpenCV using Java?

Maruthi Krishna
Updated on 09-Apr-2020 08:32:06

252 Views

The org.opencv.imgproc package of Java OpenCV library contains a class named Imgproc.To draw a circle you need to invoke the circle() method of this class. This method accepts the following parameters −A Mat object representing the image on which the circle is to be drawn.A Point object representing the center of the circle.An integer variable representing the radius of the circle.A Scalar object representing the color of the circle(BGR).An integer representing the thickness of the circle(default 1).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 org.opencv.imgproc.Imgproc; public class DrawingCircle {    public static void main(String args[]) ... Read More

Advertisements