How to select subarray from the array of 1D numpy subarrays?

def distancesplit(self):
  img = np.asarray(Image.open("testtwo.tif").convert('L'))                            
  img = 1 * (img < 127)
  area = (img == 0).sum()
  areasplit = np.split(img, 24) # splitting an image array into 24
  print areasplit
for i in areasplit: # compute white pixel area in splitted parts-arrays
  result = (i == 0).sum()
  print result
for i in areasplit: #converting 2D array inro 1D 
  b = i.ravel()
# Now I need o select from "b" 1D array the subarrays  with minimal and maximal number of white pixels. I need it for distance metrics between these subarrays. Thank you.
1

There are 1 answers

0
cyriel On

Use sum function (http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#sum) on each submatrix (row or column in this case) and then find min and max value from results.