- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Maruthi Krishna has Published 951 Articles
Maruthi Krishna
347 Views
Following Java example draws a watermark (“Hello”) on the given image and saves it back.Exampleimport java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class WaterMarkExample { public static void main(String[] args) throws IOException { //Reading the contents of an image ... Read More
Maruthi Krishna
539 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 ... Read More
Maruthi Krishna
367 Views
To convert the colored image to grayscale.Get the red green blue values of each pixelGet the average of these 3 colors.Replace the RGB values with the average.Create a new pixel value from the modified colors.Set the new value to the pixel.Exampleimport java.io.File; import java.io.IOException; import java.awt.Color; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; ... Read More
Maruthi Krishna
611 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 ... Read More
Maruthi Krishna
415 Views
To convert a negative image to positive −Read 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 the getRGB() method.To retrieve each value from a pixel you need to right shift to ... Read More
Maruthi Krishna
3K+ Views
A pixel is the smallest element of a digital image, each pixel contains the values of alpha, red, green, blue values. The pixel value(s) is stored in a 32-bit memory space holding ARGB values (8 bits each) in the same order. Therefore, to modify the color of an image −You ... Read More
Maruthi Krishna
254 Views
You can compute bitwise or between two images using the bitwise_or() method of the org.opencv.core.Core class.This method accepts three Mat objects representing the source, destination and result matrices, calculates the bitwise disjunction of each element in the source matrices and stores the result in the destination matrix.ExampleIn the following Java example, ... Read More
Maruthi Krishna
2K+ Views
You can print a list of all the existing collections in a database using show collections.ExampleAssume we have created 3 collections in a MongoDB database as shown below −> use sampleDatabase switched to db sampleDatabase > db.createCollection("students") { "ok" : 1 } > db.createCollection("teachers") { "ok" : 1 } > ... Read More
Maruthi Krishna
604 Views
Lambda expressions In Java allows you to pass functionality as an argument to a method. You can also call an existing method using lambda expressions.list.forEach(n -> System.out.println(n));Method references are simple, easy-to-read lambda expressions to call/refer and the existing method by name in a lambda expression. In addition to the instance ... Read More
Maruthi Krishna
314 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