How can I visually show that using fixed min and max for histograms is better?

1 view (last 30 days)
Faraz
Faraz on 9 Mar 2017
Commented: John BG on 9 Mar 2017
I'm classifying people based on biometric features extracted. I thought that it would be best to represent these features in a histogram before giving them to the classifier.
I tried with the matlab function 'hist' and performed classification. I got very poor results. I noticed that using a fixed min and max and forcing a histogram between these points would give better results. So I downloaded a script and generated histograms for all samples within a fixed scale. This gave very good results.
Now the problem is that I don't know how to visually represent my theorey? It does make sense that if a histogram for an unknown sample is adjusting itself for its won min and max then it would be useless for classification purposes, but let those histogms be generated within a fixed scale and it will have some identification and discriminatory power.
I thought it would be as simple as plotting both histograms, but it is not clear through that.
For example for a correct classifictaion using Matlab's hist function gives the following plot:
For a correct classification using the downloaded script generates the following plot:
Using these two figures I cannot prove my point that the second histogram displayed performs significantly better just by providing a fixed min and max.
Maybe I am looking at this from the wrong perspective. Any suggestions here would be appreciated.
edit: code for the script added below:
function h = calculate_hist(Patch, NumOfHist,MinValue,MaxValue)
%%Find patch size
m = length(Patch);
%%compute histogram size
% MaxValue= max((Patch));
% MinValue = min((Patch));
binSize = (MaxValue - MinValue)/ NumOfHist;
%%compute colour histograms
h = zeros(1,NumOfHist);
for i = 1 : m
A = floor((Patch(i)- MinValue)/binSize) + 1;
if (Patch(i) < MaxValue && A < NumOfHist+1)
h(floor((Patch(i)- MinValue)/binSize) + 1) = h(floor((Patch(i)- MinValue)/binSize) + 1)+1;
else
h(end) = h(end)+1;
end
end h = h/m;
  6 Comments
John BG
John BG on 9 Mar 2017
Hi
didn't find any calculate_hist.m in Mathworks website, yet there is this comment in Stack Overflow
.
Basically, without the script calculate_hist.m, but understanding that both histograms belong to the same set of data,
the second one looks like the 1st one with less bins which is consistent with the possibility of one of the functions only taking one image channel but keeping numel(pixels) of the image, not the channel, while the other taking all 3 image channels.
So, a histogram should see the same histogram graph, exactly the same iif RGB have exactly the same content, which means the image is Black and White, grey scale.
Yet if one of the scripts concatenates the channels back missing ';', could be a reshape with wrong parameters, if you put the channels one next to the other instead of stacking them in each image layer, then, it may be that you are taking one of the channels, erroneously lined up, or compressed, let me explain
Another possibility is despite same original image any of the following has taken place: resizing or zooming out
So a function has decimated the image, reducing the amount of points, that also happens to show a compressed or 'bonsai' version of the wider histogram
Hope it helps
John BG

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!