# Variance using median filter

2 ビュー (過去 30 日間)
Albert Tagtum 2022 年 6 月 20 日

Hi,
In calculating variance using definition and implementing median filter why does in the code
variance = medfilt2(double(I_noise).^2, [N N], 'symmetric') - (medfilt2(double(I_noise), [N N],'symmetric')).^2;
produce zero in all points of an image?
How do I correctly calculate the variance of a median filtered image?

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

### 回答 (1 件)

Jon 2022 年 6 月 20 日
variance = medfilt2(double(I_noise).^2, [N N], 'symmetric') - (medfilt2(double(I_noise), [N N],'symmetric')).^2;
both of the terms on the right hand side of the expression are identical. Subtracting one from the other will obviously give zero.
This is the same for example as the expression:
x = 2 - 2
which of course gives an answer of x = 0;
Also I think you are getting confused about median and average.

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

### カテゴリ

Find more on Image Filtering in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!