Normalizing by means of zero-mean
3 views (last 30 days)
Show older comments
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?
Answers (3)
Jos (10584)
on 18 Jul 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)
0 Comments
Jan
on 18 Jul 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);
0 Comments
DGM
on 5 Jun 2024
Edited: DGM
on 6 Jun 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
[mean2(outpict) std2(outpict)] % output statistics
imshow(outpict,'border','tight');
0 Comments
See Also
Categories
Find more on Image Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!