Articles on Trending Technologies

Technical articles with clear explanations and examples

How to flip an image using Java OpenCV library?

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

The flip() method of the Core class of OpenCV flips an image along the x/y axis. This method accepts −A source matrix congaing the data of the original image.An empty destination matrix to hold the data of the resultant image.A flip code to specify the direction of the image (0 –x axis, +ve – y axis, – ve both the axes).To flip an image −Load the OpenCV core native library, using the loadLibrary() method.Read the contents of the image file to a matrix using the imread() method.Create an empty matric to hold the result.Invoke the flip() method by passing the ...

Read More

How to create a mirror image using Java OpenCV library?

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

To create a mirror imageRead the required image using ImageIO.read() method.Get the height and width of the image.Create an empty buffered image to store the resultUsing nested for loops traverse through each pixel in the image.Iterate the width of the image from right to left.Get the pixel value using the getRGB() method.Set the pixel values to the result image object using the setRGB() method, by replacing the new width values.Exampleimport java.io.File; import java.io.IOException; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; public class MirrorImage {    public static void main(String args[])throws IOException {       //Reading the image       File file= ...

Read More

How to convert a colored image to Sepia image using Java OpenCV library?

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

Algorithm to convert a colored image to sepia −Get the red green blue values of each pixelGet the average of these 3 colors.Define the depth and intensity values (ideally 20, and 30).Modify the values as −red = red + (depth*2).Green = green +depth.blue = blue-intensity.Make sure that the modified values are between 0 to 255.Create a new pixel value from the modified colors and set the new value to the pixel.Implementation in JavaRead the required image using ImageIO.read() method.Get the height and width of the image.Using nested for loops traverse through each pixel in the image.Get the pixel value using ...

Read More

How to save the current JShell session in Java 9?

raja
raja
Updated on 08-Apr-2020 873 Views

Java 9 has introduced a new feature is the creation of a REPL (Read-Evaluate-Print-Loop) called JShell. It is a command-line prompt tool to evaluate Java code without the need to write a complete program.When we can enter code or internal commands in JShell, we need to use it during the current session. When we can close JShell and log-in again, all of the code previously entered has lost. An internal command has been implemented in order to save all code entered into a file using the "/save" command./ save [file-path] / save -all [file-path] / save -history [file-path] / save -start ...

Read More

How to convert a colored image to blue/green/red image using Java OpenCV library?

Maruthi Krishna
Maruthi Krishna
Updated on 08-Apr-2020 434 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 a colored image to grayscale you need to pass Imgproc.COLOR_RGB2BGR 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 ColorToGrayscale {    public static void main(String args[]) throws Exception {       //Loading the OpenCV core library       System.loadLibrary( Core.NATIVE_LIBRARY_NAME );   ...

Read More

How to write an image using Java OpenCV library?

Maruthi Krishna
Maruthi Krishna
Updated on 08-Apr-2020 790 Views

Using the OpenCV library you can perform image processing operations such as image filtering, geometrical image transformations, color space conversion, histograms, etc.Writing an imageWhenever you read the contents of an image using the imread() method of the Imgcodecs class the result is read into the Matrix object.You can write/save an image using the imwrite() method. This accepts two parameters namely −File − A string value representing the file path to which the result should be stored.Img − A matrix object containing the data of the image to be saved.ExampleThe following Java example reads the contents of the image cat.jpg as a ...

Read More

What is an unnamed module in Java 9?

raja
raja
Updated on 08-Apr-2020 1K+ Views

An unnamed module is a concept of the unnamed package. It is a module in which packages or classes can't be defined in any named module but exist in the jar file from classpath. If our code can try to load type from those files, the module system attempts to lookup classpath and loads it.An unnamed module read all other modules, including all of the named,  built-in platform modules, and also exports all of its packages. The package in an unnamed module can be ignored, which is also defined in the named module.The unnamed module has access to:All packages exported by all other modules available in module-path.All the jars ...

Read More

How to get complete drive information using C#?

Samual Sam
Samual Sam
Updated on 08-Apr-2020 283 Views

Drive information of an Operating System includes.Drive Name Volume Label Free Space Total Size Drive Format Drive TypeTo get above information about a drive, try to run the following code −Exampleusing System.IO; using System; class Program {    static void Main() {       DriveInfo driveInfo = new DriveInfo("D");       Console.WriteLine(driveInfo.Name);       Console.WriteLine(driveInfo.VolumeLabel);       Console.WriteLine(driveInfo.AvailableFreeSpace);       Console.WriteLine(driveInfo.TotalFreeSpace);       Console.WriteLine(driveInfo.TotalSize);       Console.WriteLine(driveInfo.DriveFormat);       Console.WriteLine(driveInfo.DriveType);    } }OutputThe following is the output −D: NTFS 76767677788 76767677788 45463434799 NTFS FixedNote − The output may vary with different Operating Systems.

Read More

How to traverse a process tree of Process API in Java 9?

raja
raja
Updated on 08-Apr-2020 408 Views

Java 9 has improved Process API, and it helps to manage and control operating system processes. Before Java 9, it has been difficult to manage and control operating system processes using Java programs. Since Java 9, new classes and interfaces have added to control the operating system process through Java programs. New interfaces like ProcessHandle and ProcessHandle.Info have added, and also new methods have added to Process class.In the below example, we can traverse a process tree (children and descendant processes) of Process API.Exampleimport java.io.IOException; public class ProcessTreeTest {    public static void main(String args[]) throws IOException {       Runtime.getRuntime().exec("cmd");   ...

Read More

How can we get an ID of the running process in Java 9?

raja
raja
Updated on 07-Apr-2020 840 Views

Java 9 has added improvements to Process API for getting PID of running process, getting children and/or descendants of a process, and also added a new class that helps to list out all running processes, getting information about an arbitrary process, and traversing process tree. The information returned by these methods can be a snapshot of processes running on the OS.In the below example, we can get an ID of the running process by using the pid() method of ProcessHandle.Examplepublic class ProcessHandleTest {    public static void main(String args[]) {       ProcessHandle processHandle = ProcessHandle.current();       System.out.println("PID of running Process: " + ...

Read More
Showing 50971–50980 of 61,248 articles
Advertisements