
Concept explainers
Explanation of Solution
Method “blur()” to makes the image blurry:
import java.awt.Graphics;
import java.awt.Image;
//define the class
public class Test
{
//define the static method
public static void main(String[] args)
{
//Create an object for DrawingPanel
DrawingPanel drawpanel = new DrawingPanel(300, 300);
//Create an object for Image
Image image = drawpanel.loadImage("Smiles.png");
//Create an object for Graphics
Graphics graph = drawpanel.getGraphics();
graph.drawString("Hello, world!", 150, 20);
//Set the panel
graph.drawImage(image, 50, 50, drawpanel);
//Call the method
blur(drawpanel);
}
//Definition of method blur
public static void blur(DrawingPanel panel)
{
//Create an object for panel
int[][] pixels = panel.getPixelsRGB();
//Create an object for length
int[][] newPixels = new int[pixels.length][pixels[0].length];
//Traverse the row
for (int row = 0; row < pixels.length; row++)
{
//Traverse the column
for (int col = 0; col < pixels[0].length; col++)
{
//Declare the required variable
int redsum = 0;
int greensum = 0;
int bluesum = 0;
int count = 0;
//Traverse the row
for (int r = row - 1; r <= row + 1; r++)
{
//Traverse the column
for (int c = col - 1; c <= col + 1; c++)
{
//Traverse the row
if (r >= 0 && r < pixels...

Want to see the full answer?
Check out a sample textbook solution
Chapter 7 Solutions
Building Java Programs: A Back To Basics Approach (5th Edition)
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





