Reference no: EM133127790
Assignment
PART A: Discrete Matlab Filter Implementation
Design in Matlab a discrete implementation for a mean (smoothing) and respectively median filter. Discrete implementation means that you are expected to implement the filter algorithms/functionality in Matlab from scratch using basic syntax, rather than using one of the already built-in Matlab filter functions, similar to the example provided here: "Matlab Examples" → "12. Prewitt, Sobel, and Roberts Gradient Operators" → "Gradient_filtering_discrete_example.m" which you can find on Blackboard in the Assignment folder.
Your code should reside in a Matlab script (.m file) which can be easily run by just calling its name from the Matlab's command window. Again, this .m file should be a Matlab script not a function.
Your two filters should be able to take as an input a small matrix provided by the user in the early part of the code, as shown in the example referred to above. Your code should be flexible enough to allow the user to provide as an input a matrix of any size they want, and still run correctly without having to manually adjust any indexes in the remaining code. The filter window size for both filters is3x3.
Your filter should be able to operate with and respectively without padding, via a user modifiable parameter included in your m-file called "padding". If padding = 0, your filter should operate without padding. When padding = 1 your filter should use padding by zeros, and if padding = 2 your filter should use padding by replication.
The filtered results for both filters should be suitably displayed in the Matlab command window when the code is run. Test your code with the following input matrix and provide the results in your report for all three types of padding, for each of the twofilters:
2
|
8
|
0
|
2
|
4
|
4
|
4
|
0
|
0
|
2
|
2
|
0
|
4
|
6
|
6
|
0
|
4
|
8
|
6
|
6
|
6
|
4
|
4
|
9
|
1
|
9
|
1
|
2
|
2
|
3
|
4
|
4
|
Make sure that you use good programming practice by suitably commenting the Matlab code from your .m file script where useful to do so, and by using appropriate code indentation in order to make reading your code more legible.