how can i solve median filter 5x5 on image on lena?
3 次查看(过去 30 天)
显示 更早的评论
hello,i have a project of image processing,it is a median filter 5x5 ,i have to use it on standart pictures like lena etc, without using toolbox coding as medfilter,etc,i have to write an algorithm for that,i am new on matlab and still have a problem on Subscripted assignment dimension mismatch. i didnt remove it , please contact with me, because i have a little time to submit it.
for i=(a+1)/2:height-((a-1)/2)
for j=(a+1)/2: height-((a-1)/2)
templena =lena(i-(a-1)/2:i+(a-1)/2,j-(a-1)/2:j+(a-1)/2);
x=median(templena);
lenaoutput(i,j)=x;
end
end
i will appreciate you , if i can solve it. thank you again
1 个评论
Geoff Hayes
2014-5-19
What is a? What is height defined to be, and should there be a width as well? Ideally, the code should process each pixel and consider the 5x5 neighbourhood around it taking care when the neighbourhood runs outside of the image.
采纳的回答
Image Analyst
2014-5-19
You need to have the outer loops scan over rows and columns, then extract a subimage and call median (if you're allowed to use that function).
windowHeight = 5;
windowWidth= 5;
[rows, columns, numberOfColorChannels] = size(grayImage);
for c = ceil(windowWidth/2) : columns - ceil(windowWidth/2)
for r = ceil(windowHeight/2) : rows - ceil(windowHeight/2)
subimage = grayImage(..............
end
end
Try to finish it.
2 个评论
Image Analyst
2014-5-19
Learn how to write a script instead of doing everything on the command line. Also learn to format your code by watching this: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Also if I take time to give you good advice, it might be good if you followed it, because there may be reasons why I didn't try to fix your existing code (like it's so bad that it's not worth fixing).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Denoising and Compression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!