how to change mean and variance values in image.

3 views (last 30 days)
I got the value of mean and variance as 111 and 46 for an image, I need to do mean=0, variance=0.005, how to do tat in matlab please provide me an ans for this, thanks.
  1 Comment
Tamir Suliman
Tamir Suliman on 2 Dec 2016
you will have to post your code and the image if possible and explain what you trying to do
If you want to subtract a scalar (that is, a 1x1 matrix) from an array, the result is the same size as the array.
mean = sum(x)/length(x)
variance = sum((x - mean(x)).^2)/(length(x) - 1);
For example, if you generate noise from a standard normal distribution with randn(N,1), you will get N samples, and if you calculate the mean and variance, you will get approximately 0 and 1. So there as well, your variance may well be larger than the mean.
Both have a totally different meaning: the mean gives you an idea where your pixels are (i.e. are they white, black, 50% gray, ...). The mean will give you an idea of what pixel color to choose to summarize the color of the complete image. The variance gives you an idea how the pixel values are spread: e.g. if your mean pixel value is 50% gray, are most of the other pixels also 50% gray (small variance) or do you have 50 black pixels and 50 white pixels (large variance)? So you could also view it as a way to get an idea how well the mean summarizes the image (i.e. with zero variance, most of the information is captured by the mean).
image - mean(image(:))
you will have something the size of the original image. You must be subtracting one scalar from another if what you end up with is a scalar.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 2 Dec 2016
Try this:
grayImage = imread('moon.tif');
subplot(2, 1, 1);
imshow(grayImage, []);
% Compute stats.
mean1 = mean2(grayImage)
sd1 = std2(grayImage)
% Make mean 0 and sd 0.005
grayImage2 = (double(grayImage) - mean1) * (0.005/sd1);
subplot(2, 1, 2);
imshow(grayImage2, []);
% Compute stats.
mean2 = mean2(grayImage2)
sd2 = std2(grayImage2)
  5 Comments
Image Analyst
Image Analyst on 4 Dec 2016
Yes. Just go directly to your segmentation techniques. Whether you consider some steps to be part of the segmentation technique, or call them "preprocessing steps" is just a matter of semantics.

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing Toolbox 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!