Why i got different standard deviation values when i apply these command for matrix called as M?

2 ビュー (過去 30 日間)
I am trying to find the local standard deviation of each pixel in an image using a neighborhood window size 3*3 centered at each pixel.However, i got different result when I run the bellow code can you tell me why please?. The MATLAB code as follow
inputimage=imread('cameraman.tif');% read the input image
input_image=double(inputimage); % convert the class
%%%the first method to compute the standard deviation
standard_method1=colfilt(input_image,[3 3],'sliding',@std);
%%%the second method to compute the standard deviation
standard_method2=stdfilt(input_image);

採用された回答

MHN
MHN 2016 年 4 月 7 日
編集済み: MHN 2016 年 4 月 7 日
The differences are just on the border of the image. The reason is that colfilt and stdfilt handle the border pixels differently. "For pixels on the borders of I, stdfilt uses symmetric padding. In symmetric padding, the values of padding pixels are a mirror reflection of the border pixels in I."
Also note that they are using different numerical method, so they might be not EXACTLY the same (if you compare them logically).
  2 件のコメント
AMMAR KAMOONA
AMMAR KAMOONA 2016 年 4 月 7 日
Thanks Thus, we can say that the first method is more accurately because it uses zero padding on border. Is that right?
MHN
MHN 2016 年 4 月 7 日
編集済み: MHN 2016 年 4 月 7 日
It depends on your application and how you like to handle the border pixels. For more applications I prefer stdfilt since the border pixels have almost the same range of values comparing with the other pixels. Anyway, We can not say which one is more accurate, they just handle the border pixels differently. Please use "Accepted Answer" if it gives you your answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by