can u pls explain it

2 visualizzazioni (ultimi 30 giorni)
sangamithra.k kunnath
sangamithra.k kunnath il 10 Giu 2015
Commentato: Image Analyst il 11 Giu 2015
function imOut = mean_imnorm(im)
% O = IMNORM(I)Image normalization
% imwrite doesnt seem to do any normalizing, so i do it here.
% normalizes to the range (0,1).
imOut = im;
% normalize
imMin = mean(imOut(:));
if (imMin < 0)
imOut = imOut + abs(imMin);
end
imOut = imOut ./ max(imOut(:));

Risposta accettata

Image Analyst
Image Analyst il 10 Giu 2015
It basically scales the input image to the range 0-1 if the original mean is negative, and scales it from (theMin/theMax) to 1 if the mean is more than 0. I don't know why they want to do it this crazy inconsistent way. You should consider just using mat2gray() which will scale the image from 0 to 1 regardless of whether the mean is negative or not. mat2gray() is the main MATLAB image normalization function that you're supposed to use. You can also use imadjust() if you want a little bit of clipping, which is good for visualization if the histogram has long tails.
  2 Commenti
sangamithra.k kunnath
sangamithra.k kunnath il 11 Giu 2015
sir.. can i use mat2gray() function for my mean and variance normalization.. please give the detail about it. why we need to do normalization on image and what it means by mean and variance normalization.
Image Analyst
Image Analyst il 11 Giu 2015
mat2gray normalizes range. That will shift the mean and scale the normalization. One place it might be useful is if you have a floating point image of something, say temperature, that has floating point units. You can display it fine with [] like this:
imshow(temperature, []);
but it you use imwrite() to save it to disk, it will mess up since imwrite wants uint8. So to convert it to uint8 you can do this to capture the whole range and quantize it to 256 gray levels:
image8 = uint8(255 * mat2gray(temperature));
imwrite(filename, image8);
image8 will be quantized with the values 0, 1, 2, 3, 4, 5, .... 254, 255.

Accedi per commentare.

Più risposte (1)

dpb
dpb il 10 Giu 2015
% normalizes to the range (0,1).
Excepting that it doesn't if mean(imOut(:))<0. In that case it adjusts by the average, but there must be values < average so they'll still be negative. For the normalization to be >= 0, the shift would have to be abs(min()) to move the smallest value to the zero point.
OTOH, if all initial values are >=0, then the if clause doesn't come into play and since the lower bound would then be 0, the final range will be [0,1].
That still leaves the case where there are individual values <0 but the mean >0; again the range output will not be constrained [0 1].
One presumes with the name this is an image and hence there aren't negative values so the problems may not show up but the routine doesn't do as advertised (if it makes a difference).

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by