need to write a function for convolving a uint8 image im with an N x N convolution kernel, G, which is of type double without using matlab builtin command, and the functions should handle boundaries in the same manners as "valid"

1 view (last 30 days)
Implement a function in MATLAB called myconv2 for convolving a uint8 image im with an N x N convolution kernel, G, which is of type double. Assume N > 1 and that N is odd. Your function should handle boundaries in the same manner as the ‘valid’ option in MATLAB. Your function header should be:
function im2 = myconv2(im, G)
The output im2 is of type double, but gray-level values in im2 do not have to be in the range [0, 1]. The only features of MATLAB that you are allowed to use are the commands function, rot90, for…end, size and floor as well as indexing, arithmetic and casting operations. Do not use any commands in the image processing toolbox.
  2 Comments
Walter Roberson
Walter Roberson on 23 Nov 2015
You did not mark your question as homework, and you did not ask a question and you did not make an attempt. I would have outright closed your Question if Image Analyst had not already answered.
John D'Errico
John D'Errico on 23 Nov 2015
Had Image Analyst not answered the question, and had Walter not closed the question, I too would have closed it. The only effort made here was to type in the text of your assignment.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 23 Nov 2015
Use 4 nested for loops. The outer two go over the larger image and specify the location of the sliding window. The inner two loop over all pixels in the sliding window.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!