Maruthi Krishna has Published 951 Articles

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

Maruthi Krishna

Maruthi Krishna

Updated on 08-Apr-2020 14:03:11

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 a colored ... Read More

Reading a colored image as grey scale using Java OpenCV library.

Maruthi Krishna

Maruthi Krishna

Updated on 08-Apr-2020 14:00:57

217 Views

The imread() method of the Imgcodecs class accepts a string value representing a file name as a parameter. This method reads the contents of the specified file into a matrix object and returns it. Using this method you can read the contents of an image.In addition to this, the Imgcodecs class ... Read More

How to write an image using Java OpenCV library?

Maruthi Krishna

Maruthi Krishna

Updated on 08-Apr-2020 13:53:05

542 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 ... Read More

Collections.replaceAll() method and List.replaceAll() method in Java

Maruthi Krishna

Maruthi Krishna

Updated on 24-Feb-2020 07:00:17

3K+ Views

The replaceAll() method of Collections interface accepts a List object, two typed parameters representing old and new values, replaces the old values with the new values in the list.Example Live Demoimport java.util.ArrayList; import java.util.Collections; import java.util.List; public class ReplaceAllExample {    public static void main(String args[]) {       List ... Read More

Non capturing groups Java regular expressions:

Maruthi Krishna

Maruthi Krishna

Updated on 21-Feb-2020 11:31:41

738 Views

Using capturing groups you can treat multiple characters as a single unit. You just need to place the characters to be grouped inside a set of parentheses. For example −(.*)(\d+)(.*)If you are trying to match multiple groups the match results of each group is captured. You can get the results ... Read More

Java regex program to match parenthesis "(" or, ")".

Maruthi Krishna

Maruthi Krishna

Updated on 21-Feb-2020 11:27:01

5K+ Views

Following regular expression accepts a string with parenthesis −"^.*[\(\)].*$";^ matches the starting of the sentence..* Matches zero or more (any) characters.[\(\)] matching parenthesis.$ indicates the end of the sentence.Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SampleTest {    public static void main( String args[] ) {   ... Read More

Regular Expression Q Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 21-Feb-2020 11:21:57

985 Views

The subexpression/metacharacter "\Q" escapes all characters up to "\E" i.e. you can escape metacharacters in the regular expressions by placing them in between \Q and \E. For example, the expression [aeiou] matches the strings with vowel letters in it.Example  Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SampleProgram {   ... Read More

Posix character classes p{Blank} Java regex

Maruthi Krishna

Maruthi Krishna

Updated on 21-Feb-2020 11:11:04

185 Views

This class matches all tabs or spaces.Example  Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class PrintableCharacters {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a string");       Scanner sc = new Scanner(System.in);       String input ... Read More

Posix character classes p{InGreek} Java regex

Maruthi Krishna

Maruthi Krishna

Updated on 21-Feb-2020 11:08:43

242 Views

This class \p{InGreek} matches Greek characters.Example Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example1 {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a string");       Scanner sc = new Scanner(System.in);       String input = ... Read More

Posix character classes p{Alnum} Java regex

Maruthi Krishna

Maruthi Krishna

Updated on 21-Feb-2020 10:59:03

495 Views

This class matches alpha numeric characters.Example  Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class AlphanumericExample {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a string");       Scanner sc = new Scanner(System.in);       String input = ... Read More

Advertisements