bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 7, Problem 21E

Explanation of Solution

Method definition for "blur":

//Define "blur" method

public static double[][] blur(double[][] picture)

{

/* Compute maximum row value */

int maximumRow = picture.length;

/* Compute maximum column value */

int maximumCol = picture[0].length;

/* Create two dimensional array for result */

double[][] result = new double[maximumRow][maximumCol];

/* Compute weighted average of the element and its neighbors */

for(int row = 0; row < maximumRow; row++)

{

for(int col = 0; col < maximumCol; col++)

{

/* Assign "total" to "0.0" */

double total = 0.0;

/* Assign count to "0" */

double countValue = 0;

/* Validate the indices for all values in "picture" array */

/* For top three values in "picture" array */

if(validateIndices(row-1,col-1,maximumRow,maximumCol))

{

total += picture[row-1][col-1];

countValue += 1;

}

if(validateIndices(row-1,col,maximumRow,maximumCol))

{

total += 2*picture[row-1][col];

countValue += 2;

}

if(validateIndices(row-1,col+1,maximumRow,maximumCol))

{

total += picture[row-1][col+1];

countValue += 1;

}

/* For middle three values in "picture" array */

if(validateIndices(row,col-1,maximumRow,maximumCol))

{

total += 2*picture[row][col-1];

countValue += 2;

}

if(validateIndices(row,col,maximumRow,maximumCol))

{

total += 4*picture[row][col];

countValue += 4;

}

if(validateIndices(row,col+1,maximumRow,maximumCol))

{

total += 2*picture[row][col+1];

countValue += 2;

}

/* For bottom three values in "picture" array */

if(validateIndices(row+1,col-1,maximumRow,maximumCol))

{

total += picture[row+1][col-1];

countValue += 1;

}

if(validateIndices(row+1,col,maximumRow,maximumCol))

{

total += 2*picture[row+1][col];

countValue += 2;

}

if(validateIndices(row+1,col+1,maximumRow,maximumCol))

{

total += picture[row+1][col+1];

countValue += 1;

}

/* Finally compute the weighted average for all elements in "picture" array */

result[row][col] = total/countValue;

}

}

/* Returns the given result */

return result;

}

Complete code:

The complete code for after implementing "blur" method is given below:

//Define "BlurMethodTest" class

public class BlurMethodTest

{

//Define "blur" method

public static double[][] blur(double[][] picture)

{

/* Compute maximum row value */

int maximumRow = picture.length;

/* Compute maximum column value */

int maximumCol = picture[0].length;

/* Create two dimensional array for result */

double[][] result = new double[maximumRow][maximumCol];

/* Compute weighted average of the element and its neighbors */

for(int row = 0; row < maximumRow; row++)

{

for(int col = 0; col < maximumCol; col++)

{

/* Assign "total" to "0.0" */

double total = 0...

Blurred answer
Students have asked these similar questions
Draw out an example of 3 systems using Lamport’s logical clock and explain the steps in words.
"Systems have become very powerful and sophisticated, providing quality information fordecisions that enable the firm to coordinate both internally and externally."With reference to the above statement compare the operations of any three data gatheringsystems today’s organisations use to aid decision making.
labmas Course Home XDocument courses/13810469/menu/a2c41aca-b4d9-4809-ac2e-eef29897ce04 There are three ionizable groups (weak acids and/or bases) in glutamic acid. Label them on the structure below Drag the appropriate labels to their respective targets. OOH [] CH3N CH CH2 CH2 IC HO Reset Help

Chapter 7 Solutions

Java: An Introduction to Problem Solving and Programming (8th Edition)

Chapter 7.2, Problem 11STQ Chapter 7.2, Problem 12STQ Chapter 7.2, Problem 13STQ Chapter 7.2, Problem 14STQ Chapter 7.3, Problem 15STQ Chapter 7.3, Problem 16STQ Chapter 7.3, Problem 17STQ Chapter 7.3, Problem 18STQ Chapter 7.3, Problem 19STQ Chapter 7.3, Problem 20STQ Chapter 7.3, Problem 21STQ Chapter 7.3, Problem 22STQ Chapter 7.4, Problem 23STQ Chapter 7.4, Problem 24STQ Chapter 7.4, Problem 25STQ Chapter 7.4, Problem 26STQ Chapter 7.4, Problem 27STQ Chapter 7.5, Problem 28STQ Chapter 7.5, Problem 29STQ Chapter 7.5, Problem 30STQ Chapter 7.5, Problem 31STQ Chapter 7.6, Problem 33STQ Chapter 7.6, Problem 34STQ Chapter 7, Problem 1E Chapter 7, Problem 2E Chapter 7, Problem 3E Chapter 7, Problem 4E Chapter 7, Problem 5E Chapter 7, Problem 6E Chapter 7, Problem 7E Chapter 7, Problem 8E Chapter 7, Problem 9E Chapter 7, Problem 10E Chapter 7, Problem 11E Chapter 7, Problem 12E Chapter 7, Problem 13E Chapter 7, Problem 14E Chapter 7, Problem 15E Chapter 7, Problem 16E Chapter 7, Problem 17E Chapter 7, Problem 18E Chapter 7, Problem 19E Chapter 7, Problem 20E Chapter 7, Problem 21E Chapter 7, Problem 1P Chapter 7, Problem 2P Chapter 7, Problem 3P Chapter 7, Problem 4P Chapter 7, Problem 1PP Chapter 7, Problem 2PP Chapter 7, Problem 3PP Chapter 7, Problem 4PP Chapter 7, Problem 5PP Chapter 7, Problem 6PP Chapter 7, Problem 7PP Chapter 7, Problem 8PP Chapter 7, Problem 9PP Chapter 7, Problem 10PP Chapter 7, Problem 11PP Chapter 7, Problem 12PP Chapter 7, Problem 13PP Chapter 7, Problem 14PP

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
The list of ten uses for surveying in areas other than land surveying.

Elementary Surveying: An Introduction To Geomatics (15th Edition)

Find the mass of the gasoline filled container in terms of kg units.

Thinking Like an Engineer: An Active Learning Approach (4th Edition)

One class is derived from another class. The subclass is the derived class, which means the subclass contains m...

Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)

The force in each member of truss and the state of members are in tension or compression.

INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)

Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
    Text book image
    Programming Logic & Design Comprehensive
    Computer Science
    ISBN:9781337669405
    Author:FARRELL
    Publisher:Cengage
    Text book image
    C++ Programming: From Problem Analysis to Program...
    Computer Science
    ISBN:9781337102087
    Author:D. S. Malik
    Publisher:Cengage Learning
    Text book image
    C++ for Engineers and Scientists
    Computer Science
    ISBN:9781133187844
    Author:Bronson, Gary J.
    Publisher:Course Technology Ptr
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24; License: Standard Youtube License