Found 2616 Articles for Java

What is morphological gradient in image processing?

Maruthi Krishna
Updated on 13-Apr-2020 10:37:50

1K+ 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 and, during erosion operation, additional pixels are removed from image boundaries, The total number of pixels added during the dilation process depends on the dimensions of the structuring element used.Morphological Gradient is the operation that is equal to the difference between dilation and erosion of an image. Each pixel value in the resulting image indicates the contrast intensity in the nearby pixels. This ... Read More

Explain morphological Closing in OpenCV using Java.

Maruthi Krishna
Updated on 13-Apr-2020 09:37:53

347 Views

Morphological operations are the set of operations that process images according to the given shapes. Erosion and dilation are the two basic morphological operations.During dilation, additional pixels are added to the image boundaries.During erosion, additional pixels are removed from the image boundaries.The total number of pixels added/removed depends on the dimensions of the structuring element used. You can perform erosion and dilation operations using the erode() and dilate() methods respectively.In addition to dilation, OpenCV provides more morphological transformations such as Opening, Closing, Morphological Gradient, Top Hat, Black Hat.Morphological ClosingThis is an operation that is equivalent to applying dilation on an ... Read More

Java example demonstrating canny edge detection in OpenCV.

Maruthi Krishna
Updated on 13-Apr-2020 09:28:20

2K+ Views

The canny edge detector is known as optimal detector since it detects only the existing edges, gives only one response per page and minimizes the distance between the edge pixels and detected pixels.The Canny() method of the Imgproc class applies the canny edge detection algorithm on the given image. this method accepts −Two Mat objects representing the source and destination images.Two double variables to hold the threshold values.To detect the edges of a given image using the canny edge detector −Read the contents of the source image using the imread() method of the Imgcodecs class.Convert it into a gray scale ... Read More

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

Maruthi Krishna
Updated on 13-Apr-2020 09:22:27

966 Views

You can add text to an image using the putText() method of the org.opencv.imgproc.Imgproc class. This method renders the specified text in the given image. It accepts −An empty mat object to store the source image.A string object to specify the desired text.A Point object specifying the position of the text.Integer constant specifying the font of the text.scale factor that is multiplied by the font-specific base size.A Scalar object specifying the color of the text.An integer value specifying the color of the textExampleimport 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 AddingText { ... Read More

How to fit ellipses around possible objects in an image using OpenCV Java?

Maruthi Krishna
Updated on 13-Apr-2020 09:20:23

202 Views

You can fit an ellipse over a shape using the fitEllipse() method of the org.opencv.imgproc.Imgproc class. This method accepts an object of MatOfPoint2f class, calculates the ellipse that would fit the given set of points and returns a RotatedRect object.Using this you can draw ellipses around the possible objects in an image. To do so, Read an image using the imread() method of the Imgproc class.Convert it into a grayscale image using the cvtColor() method of the Imgproc class.Convert the gray image to binary using the threshold() method of the Imgproc class.Find the contours in the image using the findContours() method ... Read More

How to modify the default editor of JShell in Java 9?

raja
Updated on 13-Apr-2020 09:12:48

384 Views

JShell implements REPL (Read-Evaluate-Print Loop) that reads the code from the command-line, evaluates the given snippet, and prints the result back to us.In JShell, it's possible to edit code from the default JShell editor by using JShell Editor Pad. We can also use the "/set" command to modify the default editor in order to define another one. When launching the "/edit" command, this editor can be used. In order to perform this operation, we can simply launch the "/set editor [editor]" command.Suppose we want to set the Notepad application as the default program for editing code, then just type the command: "/set editor ... Read More

How can we modify an existing module in Java 9?

raja
Updated on 10-Apr-2020 17:24:53

423 Views

The module is a named, self-describing collection of code and data. The code has been organized as a set of packages containing types like Java classes and interfaces. The data includes resources and other kinds of static information. We need to declare a module then add module-info.java at the root of the source code.Below is the template of the "module-info.java" file.module {    requires ;    requires ;    exports ;    exports ;    exports to }We can use certain command-line options that help us to modify existing modules and add dependencies to them, export ... Read More

What are the different "/vars" commands in JShell in Java 9?

raja
Updated on 10-Apr-2020 13:48:38

324 Views

JShell is an interactive command-line tool introduced in Java 9. It is also called a REPL tool that takes input, evaluates it, and prints output to the user.In the JShell tool, it's possible to list all variables created by using the internal command "/vars". We have different "/vars" commands available in the JShell tool as listed below./vars /vars [ID] /vars [Variable_Name] /vars -start /vars -all/vars: This command allows to us display the list of all active variables of the current session./vars [ID]: This command displays the variable and its value, corresponding to the entered ID. This ID corresponds to the name of ... Read More

How can we create a Service Provider interface in Java 9?

raja
Updated on 10-Apr-2020 12:19:26

196 Views

A module that provides the implementation for the Service interface contains a "provides" statement in the module descriptor file. If the module doesn’t have the "provides" statement in the module descriptor file, the service loader can't load that module.We can create the Service Provider Interface by using below steps:We create a new Module com.tutorialspoint.serviceproviderinterface.In the src/main/java directory, we create "module-info.java" file.Inside our source directory, we create the package com.tutorialspoint.serviceproviderinterface.spi.Finally, we create the interface ServiceProviderInterface that contains a method: printServiceName() to be implemented.In the below, we can define Service Provider Interface.package com.tutorialspoint.serviceproviderinterface.spi; public interface ServiceProviderInterface {    void printServiceName(); }Read More

How to draw Image Contours using Java OpenCV library?

Maruthi Krishna
Updated on 10-Apr-2020 09:15:05

1K+ 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

Advertisements