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

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 Commenti

You changed the data. If both of these plots are histograms, they are not histograms of the same data. How are you forcing a min and max? By removing the values outside of your bounds? What code are you using?
Another note: a smoother curve does not necessarily mean a better performance. Sometimes reality is not smooth.
They are plots of the histograms of the same data, The first plot is a plot of the histogram using Matlab's hist: so I'm doing:
h = hist(my_data,nbins);
plot(h)
and the second is also a plot of a histogram but generated using the code I just added to the question:
h2 = calculate_hist(my_data, nbins, min, max);
plot(h2);
The histogram generated with the fixed min and max performs much better in terms of classification.
Also I'm forced to use plot here because the script generates a histogram but doe snot display it, Since I cannot call the 'hist' function on a histogram I uased plot
Aha, so the x-axis doesn't really mean anything in your figures. That is useful information. Where did you get this code? It is quite dense, so I can't make much sense of this, but it looks like that line after the if can be replaced by
h(A) = h(A)+1;
That comment mentions colour histogram. Sounds a bit strange to me in this context. Are you sure you understand what this code is doing? Because I don't understand how this code would result in a pdf/histogram.
PS It doesn't fundamentally change anything, but I recommend using bar to plot your data if you are dealing with a histogram. People are used to seeing bar when talking about histograms. That's what confused me and apparently someone on Stackoverflow. And add the bin centers as x-coordinates, because now nobody can really compare these two plots honestly.
Thanks for your reply. The colour histogram comment was left behind by something else I was trying. Its not supposed to be there, just forgot to delete the comment along with the old code.
Got the code from a blog which explains that this generates a histogram within a provided minimum and maximum value. I'll try to find the link again and post it here.
I think you saw my stack overflow question as well then, I agree with it being confusing for me to talk about histograms and use plot but I am doing that because the histogram generated by the code above does not display in a manner as I would want, that is, comparable to matlabs histogram output.
Using the bin centres with bar works well with matlab's hist but can I apply the same for the histogram generated by the sccript above?
The line binSize = (MaxValue - MinValue)/ NumOfHist; gives a hint. It shows you that the purpose of this is to have bins of this size.
BinEdges=linspace(MinValue,MaxValue,NumOfHist)
BinCenters=BinEdges(1:(end-1))+(MaxValue - MinValue)/(2*NumOfHist);
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

Accedi per commentare.

Risposte (0)

Richiesto:

il 9 Mar 2017

Commentato:

il 9 Mar 2017

Community Treasure Hunt

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

Start Hunting!

Translated by