histogram

CIAreaHistogram inputScale factor

蓝咒 提交于 2019-12-21 04:58:14
问题 I'm building an application that uses the CIAreaHistogram Core Image filter. I use an inputCount value (number of buckets) of 10 for testing, and an inputScale value of 1. I get the CIImage for the histogram itself, which I then run through a custom kernel (see end of post) to set alpha values to 1 (since otherwise the alpha value from the histogram calculations is premultiplied) and then convert it to an NSBitmapImageRep . I then scan through the image rep's buffer and print the RGB values

Turn hist2d output into contours in matplotlib

*爱你&永不变心* 提交于 2019-12-21 04:53:37
问题 I have generated some data in Python using matplotlib.hist2d. An example of the data is seen below. As you can see this data has some contours in it found by tracing the same color throughout the plot. I see a gamma distribution centered around 0.015. I would like to take this data and gather these contours so I can see a line trace through each color level. I tried playing around with the contour function as here counts, xedges, yedges, Image = hist2d(x, y, bins=bins, norm=LogNorm(), range=[

Opacity misleading when plotting two histograms at the same time with matplotlib

点点圈 提交于 2019-12-21 04:40:17
问题 Let's say I have two histograms and I set the opacity using the parameter of hist: 'alpha=0.5' I have plotted two histograms yet I get three colors! I understand this makes sense from an opacity point of view. But! It makes is very confusing to show someone a graph of two things with three colors. Can I just somehow set the smallest bar for each bin to be in front with no opacity? Example graph 回答1: The usual way this issue is handled is to have the plots with some small separation. This is

Selecting best range of values from histogram curve

泪湿孤枕 提交于 2019-12-21 04:28:07
问题 Scenario : I am trying to track two different colored objects. At the beginning, user is prompted to hold the first colored object (say, may be a RED) at a particular position in front of camera (marked on screen by a rectangle) and press any key, then my program takes that portion of frame (ROI) and analyze the color in it, to find what color to track. Similarly for second object also. Then as usual, use cv.inRange function in HSV color plane and track the object. What is done : I took the

How to create the histogram of an array with masked values, in Numpy?

*爱你&永不变心* 提交于 2019-12-21 03:43:13
问题 In Numpy 1.4.1, what is the simplest or most efficient way of calculating the histogram of a masked array? numpy.histogram and pyplot.hist do count the masked elements, by default! The only simple solution I can think of right now involves creating a new array with the non-masked value: histogram(m_arr[~m_arr.mask]) This is not very efficient, though, as this unnecessarily creates a new array. I'd be happy to read about better ideas! 回答1: (Undeleting this as per discussion above...) I'm not

Binning of data along one axis in numpy

走远了吗. 提交于 2019-12-20 19:37:19
问题 I have a large two dimensional array arr which I would like to bin over the second axis using numpy. Because np.histogram flattens the array I'm currently using a for loop: import numpy as np arr = np.random.randn(100, 100) nbins = 10 binned = np.empty((arr.shape[0], nbins)) for i in range(arr.shape[0]): binned[i,:] = np.histogram(arr[i,:], bins=nbins)[0] I feel like there should be a more direct and more efficient way to do that within numpy but I failed to find one. 回答1: You could use np

Matplotlib histogram from numpy histogram output [duplicate]

浪尽此生 提交于 2019-12-20 12:08:23
问题 This question already has answers here : Histogram Matplotlib (5 answers) Closed 2 years ago . I have run numpy.histogram() on a bunch of subsets of a larger datasets. I want to separate the calculations from the graphical output, so I would prefer not to call matplotlib.pyplot.hist() on the data itself. In principle, both of these functions take the same inputs: the raw data itself, before binning. The numpy version just returns the nbin+1 bin edges and nbin frequencies, whereas the

side by side multiply histogram in matlab

拈花ヽ惹草 提交于 2019-12-20 10:05:18
问题 I would like to produce a plot like the following in matlab. Or may be something like this 回答1: You can use bar(...) or hist(...) to get the results you want. Consider the following code with results shown below: % Make some play data: x = randn(100,3); [y, b] = hist(x); % You can plot on your own bar chart: figure(82); bar(b,y, 'grouped'); title('Grouped bar chart'); % Bust histogram will work here: figure(44); hist(x); title('Histogram Automatically Grouping'); % Consider stack for the

Drawing Histogram in OpenCV-Python

泪湿孤枕 提交于 2019-12-20 09:38:06
问题 I was just trying to draw histogram using new OpenCV Python interface ( cv2 ). Below is the code i tried: import cv2 import numpy as np import time img = cv2.imread('zzz.jpg') h = np.zeros((300,256,3)) b,g,r = cv2.split(img) bins = np.arange(256).reshape(256,1) color = [ (255,0,0),(0,255,0),(0,0,255) ] for item,col in zip([b,g,r],color): hist_item = cv2.calcHist([item],[0],None,[256],[0,255]) cv2.normalize(hist_item,hist_item,0,255,cv2.NORM_MINMAX) hist=np.int32(np.around(hist_item)) pts = np

Matplotlib: plotting transparent histogram with non transparent edge

ぐ巨炮叔叔 提交于 2019-12-20 09:12:32
问题 I am plotting a histogram, and I have three datasets which I want to plot together, each one with different colours and linetype (dashed, dotted, etc). I am also giving some transparency, in order to see the overlapping bars. The point is that I would like the edge of each bar not to become transparent as the inner part does. Here is an example: import matplotlib.pyplot as plt import numpy as np x = np.random.random(20) y =np.random.random(20) z= np.random.random(20) fig = plt.figure() ax =