Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IMPORTANT: USE ONLY C, IF YOU'RE NOT FAMLAR C, PLEASE DON'T ANSWER THE QUESTON 1-) Source code must be commented properly. 2-) Your code needs

image text in transcribed

IMPORTANT: USE ONLY C, IF YOU'RE NOT FAMLAR C, PLEASE DON'T ANSWER THE QUESTON

1-) Source code must be commented properly.

2-) Your code needs to use dynamic memory allocation to allocate memory for processing images in memory and should free that memory properly when done.

3-) Use functions to modularize your code.

In this programming assignment, you will apply a smoothing filter on the original image. In order to apply smoothing, you need to apply a convolution operation on the image. A convolution operation uses a kernel which is a fixed size small matrix. For this assignment, we will use a 3x3 blurring kernel. The convolution operation moves this kernel over the image, shifting it one pixel at a time and takes the dot product of matrix elements with the pixel values underneath (element-wise multiplication and addition operation - see below). The filter traverses the entire image this way producing a single pixel out of 9 adjacent pixels. 100 120 110 100 120 110 0.0625 0.125 0.0625 85 98 64 46 98 64 46 * 0.125 0.25 0.125 150 80 70 150 80 70 0.0625 0.125 0.0625 Image patch Kernel (filter) Input Output 100*0.0625+120x0.125+110x0.0625+980.125+64x0.25+46x0.125+150x0.0625+80x0.125+70x0.0625 = 85.875 - 85 In this figure, each grid box represents a single pixel for simplicity. Note that similar to downscaling operation, this operation needs to be carried out separately for each color component of a pixel. That is, firstly, the kernel will be applied to R color components of 9 adjacent pixels producing the R color component of the resulting pixel; then, it will be applied to G color components of the same 9 adjacent pixels producing the G color component of the resulting pixel; and finally, it will be applied to B color components of the same 9 adjacent pixels producing the B color component of the resulting pixel. However, there is a problem. If we do not let the kernel move beyond the boundaries of the image, the resulting image will be smaller than the original image. For instance, a 3x3 kernel traversing a 90-pixel wide image left-to- right can only produce 90 - 2 convolutions without kernel exceeding image boundaries. Therefore, in this case, the resulting image would have a width of 88 pixels. In order to preserve the image size both horizontally and vertically, we apply padding to the input image by adding O valued pixels around the edges of the image. See below. 000 do 000000-00-00 Ong 10 001 MW WWW 3x3 Kernel 1010 100 100000000000000 Input Image Output Image (has the same size as the input)

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

Step: 3

blur-text-image

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

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions