In [1]:
%load_ext autoreload
%autoreload 2

In [5]:
from __future__ import division

import numpy as np
import matplotlib.pyplot as plt

import skimage
import pims

import sys
sys.path.append('/home/isaac/work/pyadisi/')

import pyadisi

In [64]:
def process_func(img):
    return skimage.img_as_float(skimage.color.rgb2gray(img))

vid_name = '/home/isaac/work/pyadisi/examples/video/snake-landing-1.mov'
vid_name = '/home/isaac/Dropbox/multisteps/rotations/3_ross/video/turn 1.mov'
vid = pims.Video(vid_name, process_func=None)


Decoding video file...
Reusing buffer from previous opening of this video.

In [ ]:
for i in range(len(vid)):
    if i == 0:
        avg_img = pyadisi.compare.process_gf(vid[i])
    else:
        avg_img += pyadisi.compare.process_gf(vid[i])
avg_img /= len(vid)

In [65]:
imshow_args = dict()

ii = 100
fig, ax = plt.subplots()
ax.imshow(vid[ii], interpolation='nearest')

fig, ax = plt.subplots()
ax.imshow(pyadisi.compare.process_gf(vid[ii]), interpolation='nearest', cmap=plt.cm.gray)


Out[65]:
<matplotlib.image.AxesImage at 0x10921510>

In [66]:
plt.close('all')

In [102]:
ii = 50
img0 = pyadisi.compare.process_gf(vid[ii - 1]) - avg_img
img1 = pyadisi.compare.process_gf(vid[ii]) - avg_img

d = pyadisi.compare.subtraction(img0, img1)
dd = skimage.exposure.rescale_intensity(d)

fig, ax = plt.subplots()
#ax.imshow(d < .15, interpolation='lanczos', cmap=plt.cm.RdBu, alpha=.5)
cax = ax.imshow(d, interpolation='lanczos', cmap=plt.cm.gray, alpha=1)
fig.colorbar(cax)

fig, ax = plt.subplots()
cax = ax.imshow(d < .15, interpolation='lanczos', cmap=plt.cm.gray)

# fig, ax = plt.subplots()
# cax = ax.imshow(dd, interpolation='nearest', cmap=plt.cm.gray)
# fig.colorbar(cax)

In [105]:
fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True, figsize=(8, 6))

ax1.imshow(img0, interpolation='lanczos', cmap=plt.cm.gray)
ax2.imshow(img1, interpolation='lanczos', cmap=plt.cm.gray)

ax1.axis('off')
ax2.axis('off')

fig.subplots_adjust(hspace=0)

fig.set_facecolor('w')
fig.tight_layout()

In [ ]:
from skimage.morphology import disk
from skimage.filter.rank import entropy

In [120]:
e0 = entropy(skimage.img_as_ubyte(img0), disk(2))
e1 = entropy(img1, disk(2))

ed = entropy(d, disk(2))

In [121]:
fig, ax = plt.subplots()
cax = ax.imshow(ed, interpolation='nearest', cmap=plt.cm.gray, alpha=1)
fig.colorbar(cax)


Out[121]:
<matplotlib.colorbar.Colorbar instance at 0x2194e9e0>

In [122]:
fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True, figsize=(8, 6))

cax1 = ax1.imshow(e0, interpolation='nearest', cmap=plt.cm.gray)
cax2 = ax2.imshow(e1, interpolation='nearest', cmap=plt.cm.gray)

fig.colorbar(cax1, ax=ax1, orientation='horizontal')
fig.colorbar(cax2, ax=ax2, orientation='horizontal')

ax1.axis('off')
ax2.axis('off')

fig.subplots_adjust(hspace=0)

fig.set_facecolor('w')
fig.tight_layout()

In [101]:
imshow(skimage.img_as_ubyte(d), interpolation='nearest', cmap=plt.cm.gray)


Out[101]:
<matplotlib.image.AxesImage at 0x19e54c50>

In [98]:
dd = skimage.exposure.rescale_intensity(d, out_range=(0, 1))

In [ ]:


In [73]:
fig, ax = plt.subplots()

ax.imshow(avg_img, cmap=plt.cm.gray)


Out[73]:
<matplotlib.image.AxesImage at 0xc616c50>

In [78]:
plt.close('all')

In [ ]: