image processing loop to calculate median value in window / kernel
古いコメントを表示
I want to slide through an image matrix and evaluate the median at each frame. The structuring element needs to be 5x5. This is what i have so far:
img = imread('img.jpg');
length = 5;
half = round(length/2);
Len = size(greyscale_Gaussian);
rows = Len(1);
cols = Len(2);
kernel = zeros(5,5);
rowend = (rows - 1);
colend = (col - 1);
for row = 3 : rows -3;
for column = 3: num_cols -3;
up = row + half;
down = rows - half;
right = column + half;
left = cols - half;
startrow = max(up), 1;
endrow = min(down), rowend;
startcolumn = max(left),1;
endcolumn = min(right),colend;
window = W(startrow:endrow, startcolumn:endcolumn); %??
window = ([up:down,right:left]); %??
B(row, column) = median(window);
end
end
Im not sure how to define the window or how to end this script? i dont want to use any inbuilt functions such as imfilter etc.
採用された回答
その他の回答 (1 件)
Image Analyst
2021 年 3 月 21 日
0 投票
Why not use the build-in function medfilt2()?
3 件のコメント
Yas Rebecca
2021 年 3 月 21 日
Image Analyst
2021 年 3 月 21 日
Then can you please accept DGM's answer to give him reputation points?
And it's almost always better to use built-in methods because they've been extensively tested for robustness and validated for accuracy, rather than your own method, which might not think of all the things that could go wrong or have bugs.
DGM
2021 年 3 月 21 日
I second Image Analyst's note about using existing tools. Not only are they typically more robust, but they're often faster. I should've added that the only reason I wrote that sliding window filter was as a fallback for use only when imdilate() wasn't available.
カテゴリ
ヘルプ センター および File Exchange で Image Preview and Device Configuration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!