Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ question - image processing question Write a program to simulate image processing .An image file is simulated by a 2D array of ints. Shell

C++ question - image processing question

Write a program to simulate image processing .An image file is simulated by a 2D array of ints. Shell code is provided in HW5_image_shell.cpp, which includes the following functions:

Process an image file (blur the image).

Print out blurred image on screen.

The screenshot below shows a sample image:

image text in transcribed

Remember, image blurring is done by calculating the weighted average of each pixel (each element of the 2D array). The weights are specified by a predefined 3 by 3 weight mask:

1 2 1

2 2 2

1 2 1

The center weight 2 (highlighted) is applied to a pixel itself and the other weights are applied to its 8 neighbors.

We will use approach 1 for pixels with less than 8 neightbors:

Approach 1: pixels with fewer than 8 neighbors are not processed

Blurred result:

image text in transcribed

For example, new value for pixel[1][1] (in yellow rectangle) would be calculated based on itself and 8 neighbors.

image text in transcribed

new value for pixel[1][1]

= (1 * 10 + 2 * 100 + 1 * 10 +

2 * 10 + 2 * 300 + 2 * 10 +

1 * 100 + 2 * 10 + 1 * 100) / 14 // 14 is the sum of the weights: 1+2+1 + 2+2+2 + 1+2+1

= 1080 / 14

= 77.14 77 is kept as the result

/ one image int image [MAX ROWT[MAX COL f 10, 100, 10, 100, 10, 100 }, 10, 300, 10, 300, 1, 300 , 100, 10, 100, 10, 100, 10, 300, 10, 300, 10, 300, 10 } ^; int imgHeight - 4; // height of image int imgWidth-6; /I width of image

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions

Question

u = 5 j , v = 6 i Find the angle between the vectors.

Answered: 1 week ago

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

Has the team been empowered to prioritize the issues?

Answered: 1 week ago

Question

b. Does senior management trust the team?

Answered: 1 week ago