Question

4. Implement convolving a kernel with an image in code (you can implement this as a function, or just as a script, whatever works for you). Specifically your code should takes two inputs: an array representing an image of size M X N and an array representing a kernel of size k × k where k is odd. Your code should pad your input image with the appropriate amount of zeros, perform the convolution, and output the resulting image. (a) Use your code to verify your answer to 2(a). (b) Use your code on the image hw2img4.tif using a box kernel, defined as $w(s,t) = \frac{1}{k^2}$, of size k x k for k = 3, 11, and 21. Show each resulting image. Discuss the impact of the choice of k on the output image. Discuss the impact of using zero padding. (c) Repeat (b) using a Gaussian kernel, defined as $w_G(s,t) = Ke^{-\frac{s^2+t^2}{2\sigma^2}}$, of size 43 × 43 where $\sigma$ = 2, and 7. Use $K = \frac{1}{2\pi\sigma^2}$. Show each resulting image. Discuss the impact of the choice of $\sigma$ on the output image. Discuss the impact of using zero padding. 5. Propose another method for padding an image (other than zero padding) to combat the impact seen in parts 4(b) and 4(c). You do not need to implement it in your code, just describe your proposed method and explain why you think it would prevent the issue seen in 4(b) and 4(c).

          4. Implement convolving a kernel with an image in code (you can implement this as a function,
or just as a script, whatever works for you). Specifically your code should takes two inputs:
an array representing an image of size M X N and an array representing a kernel of size
k × k where k is odd. Your code should pad your input image with the appropriate amount
of zeros, perform the convolution, and output the resulting image.
(a) Use your code to verify your answer to 2(a).
(b) Use your code on the image hw2img4.tif using a box kernel, defined as
$w(s,t) = \frac{1}{k^2}$,
of size k x k for k = 3, 11, and 21. Show each resulting image. Discuss the impact of
the choice of k on the output image. Discuss the impact of using zero padding.
(c) Repeat (b) using a Gaussian kernel, defined as
$w_G(s,t) = Ke^{-\frac{s^2+t^2}{2\sigma^2}}$,
of size 43 × 43 where $\sigma$ = 2, and 7. Use $K = \frac{1}{2\pi\sigma^2}$. Show each resulting image. Discuss
the impact of the choice of $\sigma$ on the output image. Discuss the impact of using zero
padding.
5. Propose another method for padding an image (other than zero padding) to combat the impact
seen in parts 4(b) and 4(c). You do not need to implement it in your code, just describe your
proposed method and explain why you think it would prevent the issue seen in 4(b) and 4(c).
        
Show more…
4. Implement convolving a kernel with an image in code (you can implement this as a function,
or just as a script, whatever works for you). Specifically your code should takes two inputs:
an array representing an image of size M X N and an array representing a kernel of size
k × k where k is odd. Your code should pad your input image with the appropriate amount
of zeros, perform the convolution, and output the resulting image.
(a) Use your code to verify your answer to 2(a).
(b) Use your code on the image hw2img4.tif using a box kernel, defined as
w(s,t) = (1)/(k^2),
of size k x k for k = 3, 11, and 21. Show each resulting image. Discuss the impact of
the choice of k on the output image. Discuss the impact of using zero padding.
(c) Repeat (b) using a Gaussian kernel, defined as
wG(s,t) = Ke^-(s^2+t^2)/(2σ^2),
of size 43 × 43 where σ = 2, and 7. Use K = (1)/(2πσ^2). Show each resulting image. Discuss
the impact of the choice of σ on the output image. Discuss the impact of using zero
padding.
5. Propose another method for padding an image (other than zero padding) to combat the impact
seen in parts 4(b) and 4(c). You do not need to implement it in your code, just describe your
proposed method and explain why you think it would prevent the issue seen in 4(b) and 4(c).

Added by Casey G.

Close

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
plz help with problem 5 only 4. Implement convolving a kernel with an image in code (you can implement this as a function, or just as a script, whatever works for you). Specifically your code should takes two inputs: an array representing an image of size M N and an array representing a kernel of size k k where k is odd. Your code should pad your input image with the appropriate amount of zeros, perform the convolution, and output the resulting image. (a) Use your code to verify your answer to 2(a). b) Use your code on the image hw2img4.t if using a box kernel,defined as of size k k for k = 3,11, and 21. Show each resulting image. Discuss the impact of the choice of k on the output image. Discuss the impact of using zero padding (c) Repeat (b) using a Gaussian kernel, defined as 2+12 Wgs,t)=Ke-22 (1) of size 43 x43 where o=2,and 7.Use K= Show each resulting image. Discuss 2T0 the impact of the choice of o on the output image. Discuss the impact of using zero padding. 5. Propose another method for padding an image (other than zero padding) to combat the impact seen in parts 4(b and 4(c). You do not need to implement it in your code,just describe your proposed method and explain why you think it would prevent the issue seen in 4(b) and 4(c).
Close icon
Play audio
Feedback
Powered by NumerAI
*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
1question-1consider-the-following-matrix-representation-of-a-4-pixel-by-4-pixel-black-and-white-image-which-we-will-call-a1101010111101100and-the-edge-detection-matrix-b-1-1-1-18-1-1-1-1if-w-03361

Consider the following matrix representation of a 4 pixel by 4 pixel black and white image, which we will call A: 1 1 0 1 0 1 0 1 1 1 1 0 1 1 0 0 And the edge detection matrix B: -1 -1 -1 -1 8 -1 -1 -1 -1 If we convolve matrix A and Matrix B, what are the values in the resulting matrix? For this answer, write your answer in the form: A, B, C, D Where each letter is replaced with the numeric value that would be found in this matrix representation: A B C D

Akash M.

can-someone-answer-part-d-q88marksbasic-design-problem-given-below-is-a-single-node-in-a-neural-networksupposing-that-d-is-4x4252and-w02030401b01and-that-the-activation-function-is-a-standar-97797

Sri K.

le-ab-where-and-are-the-fh-columns-of-c-and-b-respectively-write-function-named-columnproduct-that-takes-as-input-two-matrices-and-b-and-random-number-k-and-as-oulput-produces-the-product-c-10186

i.e. cj = Abj, where cj and bj are the jth columns of C and B respectively. Write a function named columnproduct that takes as input two matrices A and B and a random number k, and as output produces the product, C, by columns of the two matrices and the intermediate value, z, of the output matrix at the end of k iterations (the matrix z is used by MATLAB Grader to determine whether your code is correct). The function should work for any dimension of A and B and it should perform a check to see if the dimensions match and return an empty product matrix if the dimensions do not match. Specific instructions for writing the function: - Extract the dimension of A using the command size and store the result in the variables m and n. - Extract the dimension of B using the command size and store the result in the variables p and q - Use an if statement to perform a check on the dimensions to determine whether the multiplication is defined - If the multiplication is defined: - initialize the vector C as a matrix of zeros of the appropriate dimension - use a single for loop to evaluate the product C = AB. The loop counter should be the variable j. Each iteration of the for loop should evaluate the jth column of the matrix C as the product of A times the jth column of the matrix B. Also, inside the for loop, after you compute the jth column of C, insert the following commands: if isequal(j,k) z = C; end - If the multiplication is not defined, display the message 'dimensions do not match' and return an empty C vector and an empty z vector.

Madhur L.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,944 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,992 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,392 solutions

*

Transcript

-
00:01 Hello students, we will start here discussion.
00:04 Step 1, define the matrices a and b.
00:22 Matrix a 1 1 0 1 0 1 0 1 triple 1 0 double 1 double 0.
00:40 Matrix b minus 1 1 minus 1 minus 1 minus 1 1 minus 1 minus 1 minus 1 minus 1 and minus 1 minus 1 minus 1 minus 1 and here is also minus 1.
01:14 First step 2, we will start perform calculation.
01:29 Perform convolution.
01:37 At position we will do in convolution.
01:49 To perform convolution, we slide matrix b over matrix a.
02:16 Elements, element by element and multiply the corresponding elements.
02:55 Then we sum up the results for each position...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever