Normalizing by means of zero-mean
3 次查看(过去 30 天)
显示 更早的评论
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?
回答(3 个)
Jos (10584)
2013-7-18
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 个评论
Jan
2013-7-18
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 个评论
DGM
2024-6-5
编辑:DGM
2024-6-6
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!