# how to calculate mean and standard deviation, from the image then subtracted from the original image iteratively using matlab ?

5 views (last 30 days)
safa on 22 Oct 2021
Commented: Image Analyst on 23 Oct 2021
Is it meant to be the local statistical features mean and standard deviation. or it mean by mean filter or standard deviation fitter

Image Analyst on 22 Oct 2021
For local mean, use imfilter, or conv2()
kernel = ones(5)/25;
localMeanImage = conv2(double(grayImage), kernel, 'same');
For local standard deviation, use stdfilt
localSDImage = stdfilt(grayImage, ones(5));

yanqi liu on 23 Oct 2021
local statistical features mean and standard deviation. or it mean by mean filter or standard deviation fitter
sir，may be use blockproc to process, such as
clc; clear all;
fun = @(block_struct) [mean2(block_struct.data) std2(block_struct.data)];
res = blockproc(double(im),[64 64],fun);
disp(res)
167.3821 6.8601 153.7048 61.9769 169.9453 31.7836 159.2217 6.5953 126.1189 68.7267 32.4487 46.5268 130.4160 63.4436 155.5337 9.8767 80.6594 67.0647 50.1492 63.4185 126.0491 54.8252 132.7637 40.0863 86.0100 52.7884 86.2617 59.6727 123.4392 30.1970 119.4883 21.3049
##### 2 CommentsShowHide 1 older comment
Image Analyst on 23 Oct 2021
@safa, show your code. Because I don't see %{ in her code. In your code you have a %{ to start a big chunk of code as a comment, but you never have a %} to tell it where you want all those lines of code to stop being a comment. Search for %{ and %} in your code. Do you see the same number of each of them?

R2021b

### Community Treasure Hunt

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

Start Hunting!