histogram

Finding the local maxima/peaks and minima/valleys of histograms

谁都会走 提交于 2019-11-30 04:13:10
Ok, so I have a histogram (represented by an array of ints), and I'm looking for the best way to find local maxima and minima. Each histogram should have 3 peaks, one of them (the first one) probably much higher than the others. I want to do several things: Find the first "valley" following the first peak (in order to get rid of the first peak altogether in the picture) Find the optimum "valley" value in between the remaining two peaks to separate the picture I already know how to do step 2 by implementing a variant of Otsu. But I'm struggling with step 1 In case the valley in between the two

Circular Histogram for Python

点点圈 提交于 2019-11-30 03:19:59
I have periodic data and the distribution for it is best visualised around a circle. Now the question is how can I do this visualisation using matplotlib? If not, can it be done easily in Python? My code here will demonstrate a crude approximation of distribution around a circle: from matplotlib import pyplot as plt import numpy as np #generatin random data a=np.random.uniform(low=0,high=2*np.pi,size=50) #real circle b=np.linspace(0,2*np.pi,1000) a=sorted(a) plt.plot(np.sin(a)*0.5,np.cos(a)*0.5) plt.plot(np.sin(b),np.cos(b)) plt.show() There are a few examples in a question on SX for

Matplotlib histogram with errorbars

做~自己de王妃 提交于 2019-11-30 02:40:36
问题 I have created a histogram with matplotlib using the pyplot.hist() function. I would like to add a Poison error square root of bin height ( sqrt(binheight) ) to the bars. How can I do this? The return tuple of .hist() includes return[2] -> a list of 1 Patch objects. I could only find out that it is possible to add errors to bars created via pyplot.bar() . 回答1: Indeed you need to use bar. You can use to output of hist and plot it as a bar: import numpy as np import pylab as plt data = np.array

Histogram equalization not working on color image - OpenCV

北城余情 提交于 2019-11-29 20:30:39
I am trying to perform a histogram equalization using OpenCV using the following function Mat Histogram::Equalization(const Mat& inputImage) { if(inputImage.channels() >= 3) { vector<Mat> channels; split(inputImage,channels); Mat B,G,R; equalizeHist( channels[0], B ); equalizeHist( channels[1], G ); equalizeHist( channels[2], R ); vector<Mat> combined; combined.push_back(B); combined.push_back(G); combined.push_back(R); Mat result; merge(combined,result); return result; } return Mat(); } But when I get the result, there seems to be no difference in input and output image, what am I doing wrong

save a pandas.Series histogram plot to file

眉间皱痕 提交于 2019-11-29 20:23:54
In ipython Notebook, first create a pandas Series object, then by calling the instance method .hist(), the browser displays the figure. I am wondering how to save this figure to a file (I mean not by right click and save as, but the commands needed in the script). Phillip Cloud Use the Figure.savefig() method, like so: ax = s.hist() # s is an instance of Series fig = ax.get_figure() fig.savefig('/path/to/figure.pdf') It doesn't have to end in pdf , there are many options. Check out the documentation . Alternatively, you can use the pyplot interface and just call the savefig as a function to

Un-normalized Gaussian curve on histogram

最后都变了- 提交于 2019-11-29 20:14:37
问题 I have data which is of the gaussian form when plotted as histogram. I want to plot a gaussian curve on top of the histogram to see how good the data is. I am using pyplot from matplotlib. Also I do NOT want to normalize the histogram. I can do the normed fit, but I am looking for an Un-normalized fit. Does anyone here know how to do it? Thanks! Abhinav Kumar 回答1: As an example: import pylab as py import numpy as np from scipy import optimize # Generate a y = np.random.standard_normal(10000)

How to construct unequal width histograms with Matlab?

邮差的信 提交于 2019-11-29 19:33:51
问题 I would like to construct a histogram with unequal bins (intervals)..Matlab construct only histograms with equal bins as if it's a diagram..!!! Please help me...thanks a lot!! 回答1: Here's an example: x = randn(100,1)*3; %# some random data e = [-10 -5 -3 -1 1 2 3 20]; %# edges of intervals: e(i) <= x < end(i+1) c = histc(x,e); %# get count in each interval bar(e, c, 'histc') %# bar plot set(gca, 'xlim',[e(1) e(end)]) 回答2: 2 solutions: Specify bin centers with the 2nd argument to hist. Specify

How to have logarithmic bins in a Python histogram

烂漫一生 提交于 2019-11-29 19:24:58
As far as I know the option Log=True in the histogram function only refers to the y-axis. P.hist(d,bins=50,log=True,alpha=0.5,color='b',histtype='step') I need the bins to be equally spaced in log10. Is there something that can do this? HYRY use logspace() to create a geometric sequence, and pass it to bins parameter. And set the scale of xaxis to log scale. import pylab as pl import numpy as np data = np.random.normal(size=10000) pl.hist(data, bins=np.logspace(np.log10(0.1),np.log10(1.0), 50)) pl.gca().set_xscale("log") pl.show() The most direct way is to just compute the log10 of the limits,

how to plot rgb color histogram of image with objective c

不羁的心 提交于 2019-11-29 18:06:24
i want to show image RGB colour histogram in cocoa application. Please suggest possible way to do it with objective c or any third party library available to achieve this. Spektre well this is a problem as RGB colors are 3D space so their histogram would lead to 4D plot which is something we do not really comprehend. So the solution to this is to convert the 4D plot to 3D plot somehow. This can be done by sorting the colors by something that has some meaning. I will not speculate and describe what I am using. I use HSV color space and ignore the V value. This way I lose a lot of color shade

Java: Paint a histogram via fillRect()

可紊 提交于 2019-11-29 18:05:57
I like to make a histogram. With drawLine() , it's not really a problem for me, but when I try to do it with fillRect() the rectangles are going from top to bottom. I would like to paint the histogram looking similar to my histogram with drawLine() . Here is my code: public void paint(Graphics g) { super.paint(g); int height = getHeight(); int width = getWidth(); int x =10; haufigkeit=model.getMap(); for(int i = 1; i <= 45; i++) { int y; y = haufigkeit.get(i); Color color = new Color(0, 0, (int)(150 + Math.random() * 100)); g.setColor(color); // g.fillRect(x, 50, 10, y); // g.drawLine(x,