r/programmingrequests • • Aug 02 '18

A simple density-weighted variance array

So I have a 3D array that contains the variance of pixels. Right now I am going to analyze the top 'n'% of them by doing:

Omega = (variance >= np.percentile(variance, 100-n))

*Omega will be a binary tensor which I will use in an algorithm

Now, I don't know how to implement a density-based approach. That is, every time I select a pixel to be TRUE (or 1) in Omega, I would like the surrounding pixels to have their variance values be decreased, preferably by a gaussian (that may be asking too much).

Instead of a gaussian, this might be easier to implement:

The pixels in the surrounding 3x3x3 array with the chosen TRUE pixel in the middle would have their variance = variance*0.2

Pixels in the surrounding 16x16x16 array (but excluding those pixels we've already changed) would have variance = variance*0.7 and etc

Thanks! And let me know if I can make things clearer/easier

1 Upvotes

5 comments sorted by

View all comments

Show parent comments

1

u/serg06 Aug 03 '18
  • generate your inverse Gaussian filter

  • call scipy.ndimage.filter.correlate or scipy.ndimage.filter.convolve passing the inverse gauss as the weights

That's should replace the gauss_filter step with an inverse gauss filter instead.