how can i perform gray scale image normalization???
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i want to implement normalization to gray scale image to reduce the effect of illumination's differences.
the eq. of the grayscale normalization is :
y=((x-min)*255/(max-min))
x : gray scale value of original image.
y : gray scale value of op image(after normalization).
min : minimum gray scale for the original image.
max : maximum gray scale for the original image.
i tried to perform this by :
m=imread();
min1=min(min(m));
max1=max(max(m));
y=((m-min1).*255)./(max1-min1);
imshow(m);figure,imshow(y);
but it is wrong code .
i dont know why ?
is there any help?
regards
5 commentaires
Xylo
le 11 Mar 2014
you can use double() before main function....
y=double((m-min1).*255./(max1-min1)); and as m is a 2D variable, y should be 2D variable. i.e u have to write as for i=1:m for j=1:n y(i,j)=double((m(i,j)-min1).*255./(max1-min1)); end end
Réponses (3)
Image Analyst
le 19 Jan 2012
Or you can simply do this:
normalizedImage = uint8(255*mat2gray(grayImage));
imshow(normalizedImage);
and not worry about the normalization because mat2gray will do it for you.
4 commentaires
Image Analyst
le 19 Jan 2012
Then maybe their algorithm uses image normalization as just one step in the process and maybe you're not doing all the steps. Or else maybe their algorithm is not appropriate for the kind of video or images you have.
Syed Ahson Ali Shah
le 8 Fév 2022
Modifié(e) : Syed Ahson Ali Shah
le 10 Fév 2022
This is the Formula:
Normalized Image = (Original image - min of image) * ((newMax-newMin) / (ImageMax - ImageMin)) + newMin
where newMax and newMin is 255 and 0 respectively for the case when normalization is between 0 to 255.
2 commentaires
Image Analyst
le 8 Fév 2022
No it's not:
Originalimage = [100, 200]
minofimage = min(Originalimage(:));
ImageMin = min(Originalimage(:));
ImageMax = max(Originalimage(:));
newMax = 255;
newMin = 0;
% Do the formula he gave.
NormalizedImage = (Originalimage - minofimage) * ((newMax-newMin) / (ImageMax - ImageMin)) + newMax
% Do my formula:
normalizedImage = uint8(255*mat2gray(Originalimage))
Syed Ahson Ali Shah
le 10 Fév 2022
There was typo mistake. I corrected now.
My answer is 100% correct. I guarantee
Walter Roberson
le 18 Jan 2012
I would suggest you use
y = uint8(255 .* ((double(m)-min1)) ./ (max1-min1));
With your existing code, the (x-min) would be okay, but multiplying by 255 would get saturation to 255 whenever the difference was not 0, and then you would get integer division of that 0 or 255 by the range interval.
5 commentaires
Walter Roberson
le 19 Jan 2012
You should be able to extrapolate.
y = uint8(255 .* ((double(m)-double(min1))) ./ double(max1-min1));
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!