Question

Write a function in Matlab (or Java) as follows: function Img2=Convolution(Img, mask); %Input: Img is the original image data matrix, mask is square matrix, could be 2x2, 3 x 3 or size %Output: Img...

  1. Write a function in Matlab (or Java) as follows:

function Img2=Convolution(Img, mask);

%Input: Img is the original image data matrix, mask is square matrix, could be 2x2, 3 x 3 or size

%Output: Img2 is the result image

  1. Test the function.

Read an image file, apply the edge detection filters (i.e., masks) to see whether it works well. Try at least 3 filters: Sobel, Robert, Prewitt.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot of code and corresponding output :-

Run Section Figure 2 File Edit View Inser Tool: Deskto Windo Hel Figure 1 Breakpoints Run Run and E Advance Run and le Edit V

Figure title says about type of filter applied...

Code in text format ..

function Img2=Convolution(Img, mask)

%Input: Img is the original image data matrix, mask is square matrix,

% could be 2x2, 3 x 3 or size

%Output: Img2 is the result image

clc;

img = imread(Img); % Reading the input file

if size(img,3) == 3

img = rgb2gray(img); % Conversion to grayscle if the image is rgb

end

Img2 = conv2(img,mask,'same'); % Applying 2d Convolution with mask

% imshow(Img2); %Showing the image

end

Add a comment
Know the answer?
Add Answer to:
Write a function in Matlab (or Java) as follows: function Img2=Convolution(Img, mask); %Input: Img is the original image data matrix, mask is square matrix, could be 2x2, 3 x 3 or size %Output: Img...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello, I need help with the following question in MATLAB for digital image processing, thank you ...

    Hello, I need help with the following question in MATLAB for digital image processing, thank you for your help in advance Convolution operations using mask are commonly applied in image enhancement. Even edge detection is based on convolution with a specially designed mask. The assignment here is to write your own function for convolution and test it in edge detection. 1. Write a function in Matlab as follows: function Img2 Convolution(Img, mask); %Input: Img is the original image data matrix,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT