5 x 5 median filter with out inbuilt function

조회 수: 11 (최근 30일)
Matthew Worker
Matthew Worker 2021년 10월 4일
편집: John Kelly 2021년 12월 8일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Digital Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by