I have a noisy unnormal 2D gaussian array with unknown location, as well as unknown mean and variance. How can I compute the gaussian's center location and its width and height in a certain confidence level?
For sample case like a perfect normal 2D gaussian:
def gauss2d(shape=(200,200),sigma=20):
m,n = [(ss-1.)/2. for ss in shape]
y,x = np.ogrid[-m:m+1,-n:n+1]
h = np.exp( -(x*x + y*y) / (2.*sigma*sigma) )
h[ h < np.finfo(h.dtype).eps*h.max() ] = 0
h = h / h.max()
return h[:150, :150]
skimage.io.imshow(gauss2d()) # it looks like the following
I can use arg.max()
of each pixel to get the center location, but for a noisy case I may need to use arg.max()
of each 3x3
size pixels to robustly compute the center. How can I achieve that with python?
I have no idea how to compute the width and height. I am also thinking use some density-based clustering method to give the location info, such as scikit-learn's DBSCAN, but do not know how to do it practically.
Many thanks in advance!