can u pls explain it
显示 更早的评论
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(:));
采纳的回答
更多回答(1 个)
dpb
2015-6-10
0 个投票
% 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).
类别
在 帮助中心 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!