In [1]:
!pip freeze


Jinja2==2.7.3
MarkupSafe==0.23
Pillow==2.7.0
PyYAML==3.11
Pygments==2.0.2
Theano==0.6.0
argparse==1.2.1
backports.ssl-match-hostname==3.4.0.2
certifi==14.05.14
holoviews==0.7
ipython==3.0.0
jsonschema==2.4.0
mahotas==1.2.4
matplotlib==1.4.3
mistune==0.5
mock==1.0.1
-e git+git@github.com:Neuroglycerin/neukrill-net-tools.git@fbc052029973dfd05395a5b8601e9f68560f59e2#egg=neukrill_net-master
nose==1.3.4
numpy==1.9.1
param==1.2.1
ptyprocess==0.4
py==1.4.26
-e git+https://github.com/lisa-lab/pylearn2.git@cf3999e7183f8dcaccccf4dfd2a31bbe3a948a97#egg=pylearn2-neukrillnetchosencommit
pyparsing==2.0.3
pytest==2.6.4
python-dateutil==2.4.0
pytz==2014.10
pyzmq==14.5.0
scikit-image==0.10.1
scikit-learn==0.15.2
scipy==0.14.0
six==1.8.0
terminado==0.5
tornado==4.1
wsgiref==0.1.2

In [2]:
%pylab


Using matplotlib backend: agg
Populating the interactive namespace from numpy and matplotlib

In [3]:
%matplotlib inline

In [4]:
cd ..


/home/scott/Documents/git/neukrill-net-work

In [5]:
cd ../neukrill-net-work


/home/scott/Documents/git/neukrill-net-work

In [6]:
import sys
import numpy as np
import skimage.io

In [7]:
import imp

In [8]:
import neukrill_net.utils as utils
import neukrill_net.image_processing as image_processing
import neukrill_net.augment as augment

In [9]:
from IPython.display import display
from IPython.display import Image
from IPython.display import HTML

In [10]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

In [11]:
img = skimage.io.imread('data/train/acantharia_protist/100224.jpg')

In [14]:
type(img)


Out[14]:
numpy.ndarray

In [15]:
img.shape


Out[15]:
(66, 59)

In [16]:
imgplot = plt.imshow(img)
imgplot.set_cmap('gray')



In [17]:
imgplot = plt.imshow(image_processing.flip_image(img, flip_x=True))
imgplot.set_cmap('gray')



In [18]:
imgplot = plt.imshow(image_processing.rotate_image(img, 360))
imgplot.set_cmap('gray')



In [19]:
imgplot = plt.imshow(image_processing.flip_image(image_processing.rotate_image(img, 180), flip_x=True))
imgplot.set_cmap('gray')



In [20]:
imgplot = plt.imshow(img)
imgplot.set_cmap('gray')



In [21]:
imgplot = plt.imshow(img[10:,:])
imgplot.set_cmap('gray')



In [24]:
imp.reload(image_processing)

processingFunction = augment.augmentation_wrapper({'rotate':3,'rotate_is_resizable':True})
imList = processingFunction(img)
for augImg in imList:
    iplot = plt.imshow(augImg)
    iplot.set_cmap('gray')
    show()


/home/scott/Documents/git/neukrill-venv2/local/lib/python2.7/site-packages/skimage/util/dtype.py:107: UserWarning: Possible precision loss when converting from float64 to uint8
  "%s to %s" % (dtypeobj_in, dtypeobj))

In [25]:
for augImg in imList:
    print(augImg)


[[255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 ..., 
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]]
[[255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 ..., 
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]]
[[255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 ..., 
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]
 [255 255 255 ..., 255 255 255]]

In [26]:
for augImg in imList:
    foo = augImg
    print(foo.dtype)
    print(skimage.dtype_limits(foo))
    print(foo.dtype == np.dtype(np.float64))


uint8
(0, 255)
False
uint8
(0, 255)
False
uint8
(0, 255)
False

In [27]:
imp.reload(image_processing)

processingFunction = augment.augmentation_wrapper({'rotate':8,'rotate_is_resizable':True,'flip':True,'crop':True,'resize':(50,50)})
imList = processingFunction(img)
print(len(imList))
for augImg in imList:
    print(augImg.dtype)
    iplot = plt.imshow(augImg)
    iplot.set_cmap('gray')
    show()


80
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64

In [33]:
imp.reload(image_processing)
imp.reload(augment)

processingFunction = augment.augmentation_wrapper({'rotate':3,'rotate_is_resizable':True,'flip':False,'traslations':[0,10],'shape':(50,50)})
imList = processingFunction(img)
print(len(imList))
for augImg in imList:
    print(augImg.dtype)
    iplot = plt.imshow(augImg)
    iplot.set_cmap('gray')
    show()


18
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64
float64

In [14]:
reload(image_processing)


Out[14]:
<module 'neukrill_net.image_processing' from '/home/scott/Documents/git/neukrill-net-tools/neukrill_net/image_processing.py'>

In [28]:
augImg = image_processing.shear_image(img, 10)
iplot = plt.imshow(augImg)
iplot.set_cmap('gray')
show()



In [29]:
iplot = plt.imshow(skimage.transform.swirl(img,cval=1.0))
iplot.set_cmap('gray')
show()