built the fuction from scratch
5 views (last 30 days)
Show older comments
a = input('Please input the matrix like "[1, 2; 3, 4]":');
% mf= ones(3,3)
% meanA = mean(A(:))
a1= padarray(a,[1 1],1)
for j =2:(n-1)
i made the mean filter that takes the matrix input and perform mean
but my teacher asked me to make this filter from scratch .how i can it
DGM on 21 Aug 2021
Edited: DGM on 21 Aug 2021
What exactly is the problem you're having? It seems like what you have is mostly there. There are a few points:
Don't use input() for collecting data. This is unnecessarily tedious and error-prone. Data can be defined in an external image or mat file, or for small test arrays in an ad-hoc script, it can just be a simple literal or even generated programmatically. There's no reason to force the user to type it in manually every single time.
I'm not sure why you're taking ceil() on the output. Nothing here implies that the input or output are strictly integer-valued. If integer output is required, scale/cast the data to an integer class so that it's compatible with what imwrite() or imread() might expect.
vrow isn't used for anything
The routine is only capable of a 3x3 rectangular filter. That may satisfy the requirements, but would be limiting for a practical filter. Whether or not that matters is up to you and what those requirements are.
Lastly, this isn't yet a function. It's still just a script. If it's required to implement this as a function, you'll have to do that.
Find more on Computer Vision With Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!