how can i solve median filter 5x5 on image on lena?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
fatma
am 18 Mai 2014
Kommentiert: Image Analyst
am 19 Mai 2014
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 Kommentar
Geoff Hayes
am 19 Mai 2014
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.
Akzeptierte Antwort
Image Analyst
am 19 Mai 2014
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 Kommentare
Image Analyst
am 19 Mai 2014
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).
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Denoising and Compression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!