Maruthi Krishna has Published 558 Articles

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

Maruthi Krishna

Maruthi Krishna

Updated on 08-Apr-2020 14:06:04

431 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

How to write an image using Java OpenCV library?

Maruthi Krishna

Maruthi Krishna

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

787 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

Non capturing groups Java regular expressions:

Maruthi Krishna

Maruthi Krishna

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

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

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

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

Custom UnaryOperator implementation in java.

Maruthi Krishna

Maruthi Krishna

Updated on 20-Feb-2020 12:04:09

491 Views

The java.util.function.UnaryOperator interface and can be used as assignment target for lambda expressions, it represents operation on a single operand whose result will be of same type as the input. We can create our own UnaryOperator by implementing this interface.The replaceAll() method of the List interface accept an object of ... Read More

Character class: union - Java regular expressions

Maruthi Krishna

Maruthi Krishna

Updated on 13-Jan-2020 06:52:15

606 Views

The character classes in Java regular expression is defined using the square brackets "[ ]", this subexpression matches a single character from the specified or, set of possible characters. For example the regular expression [abc] matches a single character a or, b or, c.The union variant of the character class ... Read More

Matching multiple lines in Java regular expressions

Maruthi Krishna

Maruthi Krishna

Updated on 13-Jan-2020 06:44:13

1K+ Views

To match/search a input data with multiple lines −Get the input string.Split it into an array of tokens by passing "\r?" as parameter to the split method.Compile the required regular expression using the compile() method of the pattern class.Retrieve the matcher object using the matcher() method.In the for loop find ... Read More

Named captured groups Java regular expressions

Maruthi Krishna

Maruthi Krishna

Updated on 13-Jan-2020 06:36:49

3K+ Views

Named capturing groups allows you to reference the groups by names. Java started supporting captured groups since SE7.Example Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class ReplaceAll{    public static void main(String[] args) {       Scanner sc = new Scanner(System.in);       System.out.println("Enter input text: ");   ... Read More

Replacing all the matched contents Java regular expressions

Maruthi Krishna

Maruthi Krishna

Updated on 13-Jan-2020 06:34:25

2K+ Views

Once you compile the required regular expression and retrieved the matcher object by passing the input string as a parameter to the matcher() method.You can replace all the matched parts of the input string with another str4ing using the replaceAll() method of the Matcher class.This method accepts a string (replacement ... Read More

Advertisements