Histogram dips on normalization
Ältere Kommentare anzeigen
So I'm trying to replicate this histogram figure:

But my end result is this:

Where there are dips on green and blue channel. I'm not sure what to do
clear all;
close all;
clc;
% read and convert image into double
palm = imread('palm down.jpg');
doublePalm = im2double(palm);
%split into RGB
redPalm = doublePalm(:,:,1);
greenPalm = doublePalm(:,:,2);
bluePalm = doublePalm(:,:,3);
%normalize count
redPalm = (redPalm-min(redPalm(:)))/(max(redPalm(:))-min(redPalm(:)));
[yRed, xRed] = imhist(redPalm);
greenPalm = (greenPalm-min(greenPalm(:)))/(max(greenPalm(:))-min(greenPalm(:)));
[yGreen, xGreen] = imhist(greenPalm);
bluePalm = (bluePalm-min(bluePalm(:)))/(max(bluePalm(:))-min(bluePalm(:)));
[yBlue, xBlue] = imhist(bluePalm);
%mean
meanRed = mean2(redPalm);
figure;
subplot(1,2,1); plot(xRed, yRed, 'Red', xGreen, yGreen, 'Green', xBlue, yBlue, 'Blue'); title('RGB Channel'); xlabel('Intensity'); ylabel('Normalised Count');
2 Kommentare
KALYAN ACHARJYA
am 21 Dez. 2018
Please attach image "palm down.jpg"
Jason Tan
am 21 Dez. 2018
Antworten (2)
KALYAN ACHARJYA
am 21 Dez. 2018
0 Stimmen
The given image is quite large, therefor I have checkd with other images and Its works fine.

Have you plot it individually?
Image Analyst
am 21 Dez. 2018
Bearbeitet: Image Analyst
am 21 Dez. 2018
0 Stimmen
Like Kalyan said, he doesn't get it. So I think you're showing a histogram of a uint8 image that has undergone contrast stretching.
When you do intensity normalization, that's what happens - you get "holes" or empty bins in the histogram because there are some gray levels that never got anything assigned to them. Let's take an example. Let's say gray level 200 got assigned to 151.4 gray levels. Then let's say gray level 201 got assigned to 152.6 gray levels. That's not much more than a gray level apart. Now, when you go to uint8, the 151.4 will go to 151, and the 152.6 will go to 153. So what went to 152? Answer: nothing! Ta-Da! Zero height bins in your histogram just like you got!
You might try using mat2gray() and see if that fixes it.
If that doesn't fix it, then you can add a plus or minus half a gray level of noise to your image before you normalize. That should fix it.
Kategorien
Mehr zu Histograms finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
