Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>import numpy as np import scipy import scipy.ndimage as ndimage import scipy.ndimage.filters as filters import matplotlib.pyplot as plt fname = '/tmp/slice0000.png' neighborhood_size = 5 threshold = 1500 data = scipy.misc.imread(fname) data_max = filters.maximum_filter(data, neighborhood_size) maxima = (data == data_max) data_min = filters.minimum_filter(data, neighborhood_size) diff = ((data_max - data_min) &gt; threshold) maxima[diff == 0] = 0 labeled, num_objects = ndimage.label(maxima) slices = ndimage.find_objects(labeled) x, y = [], [] for dy,dx in slices: x_center = (dx.start + dx.stop - 1)/2 x.append(x_center) y_center = (dy.start + dy.stop - 1)/2 y.append(y_center) plt.imshow(data) plt.savefig('/tmp/data.png', bbox_inches = 'tight') plt.autoscale(False) plt.plot(x,y, 'ro') plt.savefig('/tmp/result.png', bbox_inches = 'tight') </code></pre> <p>Given <strong>data.png</strong>:</p> <p><img src="https://i.stack.imgur.com/rdEYd.png" alt="enter image description here"></p> <p>the above program yields <strong>result.png</strong> with <code>threshold = 1500</code>. Lower the <code>threshold</code> to pick up more local maxima:</p> <h2><img src="https://i.stack.imgur.com/86XgT.png" alt="enter image description here"></h2> <p><strong>References</strong>:</p> <ul> <li><a href="https://stackoverflow.com/a/5304140/190597">J.F. Sebastian counts nuclei</a> </li> <li><a href="https://stackoverflow.com/questions/4087919/how-can-i-improve-my-paw-detection">Joe Kington finds paw prints</a></li> <li><a href="https://stackoverflow.com/a/3689710/190597">Ivan finds local maximums</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload