In [14]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [15]:
import cv2
import cv
import numpy as np
import pylab as pl
from sleepysnail.preprocessing import ROISplitter

In [16]:
grid_img = cv2.imread("grid_test.jpg")
grid_grey = cv2.cvtColor(grid_img, cv.CV_BGR2GRAY)
roi_splitter = ROISplitter(grid_grey)
pl.imshow(grid_img)


Out[16]:
<matplotlib.image.AxesImage at 0x4cde1d0>

In [25]:
pl.imshow(roi_splitter.split(grid_img, 0))


Out[25]:
<matplotlib.image.AxesImage at 0x63e78d0>

In [32]:
rois = roi_splitter.rois

x_centers = np.array([float(c+d)/2.0 for a,b,c,d in  rois])
x_mean = np.mean(x_centers)
left_rois = np.array([ r for r, xc in  zip(rois,x_centers) if xc < x_centers])


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-32-6b17b8b2a533> in <module>()
      3 x_centers = np.array([float(c+d)/2.0 for a,b,c,d in  rois])
      4 np.mean(x_centers)
----> 5 left_rois = np.array([ r for r, xc in  zip(rois,x_centers) if xc < x_centers])

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

In [ ]: