5 x 5 median filter with out inbuilt function

23 次查看(过去 30 天)
I am required to use just median() not medfilt2()
Please help with the code
%% 2. Median Filter
sad1=imread('sadimg.bmp'); %a) Read ‘sadimg.bmp’ store image into ‘sad1’
median_filt=; %b) Make a function ‘median_filt’
re_sad1=; %c) Using ‘medain_filt’, Apply 5x5 median filter to ‘sad1’store result ‘re_sad1’

回答(1 个)

Image Analyst
Image Analyst 2021-10-4
I think it wants you do use a double for loop:
[rows, columns] = size(sad1);
re_sad = .....
for col = 1 : columns
for row = 1 : rows
subImage = ..........
re_sad(row, col) = med(.............
end
end
  1 个评论
Image Analyst
Image Analyst 2021-10-4
You need to get a 5x5 subimage at each location and then take the median of that. Here's a hint:
data = randi(99, 6, 6) % Create sample data
subMatrix = data(2:5, 3:4) % Extract a submatrix
data =
69 76 71 12 75 55
32 79 75 50 26 14
95 19 28 96 51 15
4 49 68 34 70 26
44 45 65 58 89 84
38 64 17 23 95 26
subMatrix =
75 50
28 96
68 34
65 58

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by