can u pls explain it
Show older comments
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(:));
Accepted Answer
More Answers (1)
dpb
on 10 Jun 2015
0 votes
% 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).
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!