Normalizing by means of zero-mean

3 vues (au cours des 30 derniers jours)
Valeska Pearson
Valeska Pearson le 18 Juil 2013
Modifié(e) : DGM le 6 Juin 2024
Hello friends,
I am working on retinal images and need to make them standard before processing, because some images are dark others are very light. So before processing I am doing the following:
gemiddeld=mean2(DOG)
standaard_afwyking=std2(DOG)
NormalizedArray = (DOG-gemiddeld) ./ standaard_afwyking;
NormalizedArray =((NormalizedArray + 3)./ 6).*255
figure,imshow(NormalizedArray);
This is not working, because the output is just a blank white image.How can I fix this?
  1 commentaire
Valeska Pearson
Valeska Pearson le 18 Juil 2013
DOG, is my difference of Gaussian image in the green channel.

Connectez-vous pour commenter.

Réponses (3)

Jos (10584)
Jos (10584) le 18 Juil 2013
The problem is with the values you pass to IMSHOW. So, first read the help of imshow carefully
doc imshow
To fix this in your case, make sure NormalizedArray is, for instance, a true grayscale image
NormalizedArray = magic(50) ;
subplot(2,2,1) ; imshow(NormalizedArray)
GS = NormalizedArray ./ max(NormalizedArray(:)) ;
subplot(2,2,2) ; imshow(GS)

Jan
Jan le 18 Juil 2013
What is the type of DOG? Notice, that if NormalizedArray is a double array, all values greater than 1.0 are saturated. The multiplication by 255 looks like you want the image stored as UINT8 array. Then perhaps this helps:
NormArrayU8 = uint8(((NormalizedArray + 3) ./ 6) .* 255);

DGM
DGM le 5 Juin 2024
Modifié(e) : DGM le 6 Juin 2024
I'm going to stick this here and close the duplicate threads. What's missing from this form of the question is that the input images are integer-class. It's not just that the output needs to be properly scaled for its class in order to display correctly. You're normalizing the image in integer class, so your image is destroyed from rounding anyway.
Unless you're being careful, keep images properly-scaled for their class, and if you need to do gross rescaling or shifting outside the dynamic range of an integer class, then use floating point.
% an image of any standard numeric class
inpict = imread('tire.tif');
% parameters in unit scale
% these are the same as what's given
newmu = 1/2; % i.e. 3/6
newsig = 1/6;
inpict = im2double(inpict); % put the image in unit scale
mu = mean2(inpict);
sig = std2(inpict);
outpict = (inpict-mu)/sig;
outpict = outpict*newsig + newmu; % this is equivalent
% outpict = im2uint8(outpict); % if you want the output to always be uint8
[mu sig] % input statistics
ans = 1x2
0.2104 0.2438
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
[mean2(outpict) std2(outpict)] % output statistics
ans = 1x2
0.5000 0.1667
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
imshow(outpict,'border','tight');

Community Treasure Hunt

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

Start Hunting!

Translated by