Median Filter code problem:
Show older comments
Hello Dear Experts,
I am trying to build the median filter with given window size. Here is what I did so far, please correct me because for some reason I don't get the right results:
function [ newImg ] = myMedian( img, rows, cols )
ModifyImg = padarray(img,[1 1]);
for i = 1:(size(ModifyImg,1) - 2)
for j = 1:(size(ModifyImg,2) - 2)
window = zeros(rows,cols);
inc = 1;
for x = 1:rows
for y = 1:cols
window(inc) = ModifyImg(i + x - 1, j + y - 1);
inc = inc + 1;
end
end
Sorted_Window = sort(window);
newImg(i,j) = Sorted_Window(ceil(0.5*rows*cols));
end
end
end
Accepted Answer
More Answers (1)
Hammad Moussa
on 30 May 2021
0 votes
you can help me for fonction filtre media and filtre gaussian script. m
2 Comments
Image Analyst
on 30 May 2021
Is this an answer to @Steve, who posted this 9 years ago? I doubt he will help you, and doubt he will even see your answer/question. You'd be best off posting your own question after reading this:
Steve Solun
on 30 May 2021
@Image Analyst Actually it was a great nostalgy to see this question, wow 9 years ago :)
So I do see and get updates :)
@Hammad MoussaI think you can easily find a tutorial for what you're asking by searching G.
Categories
Find more on Neighborhood and Block Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!