In [1]:
%matplotlib inline

from microscopestitching import stitch
from skimage.io import imsave, imshow

In [2]:
!ls r*png


r0-c0.png r0-c2.png r1-c1.png r2-c0.png r2-c2.png r3-c1.png
r0-c1.png r1-c0.png r1-c2.png r2-c1.png r3-c0.png r3-c2.png

In [3]:
def img_tuple(img):
    row = int(img[1])
    col = int(img[4])
    return img, row, col

In [4]:
files = !ls r*png
images = [img_tuple(f) for f in files]
# path, row, column
images[:3]


Out[4]:
[('r0-c0.png', 0, 0), ('r0-c1.png', 0, 1), ('r0-c2.png', 0, 2)]

In [5]:
merged = stitch(images)


/Users/arve/Dokumenter/git/microscopestitching/microscopestitching/stitching.py:209: UserWarning: Expected images on top of each other to have zero x-offset. r1-c1.png has offset [-58   1]
  "%s has offset %s" % (image.path, image.translation[0]))
/Users/arve/Dokumenter/git/microscopestitching/microscopestitching/stitching.py:209: UserWarning: Expected images on top of each other to have zero x-offset. r1-c2.png has offset [-59   2]
  "%s has offset %s" % (image.path, image.translation[0]))
/Users/arve/Dokumenter/git/microscopestitching/microscopestitching/stitching.py:209: UserWarning: Expected images on top of each other to have zero x-offset. r2-c1.png has offset [-60  -1]
  "%s has offset %s" % (image.path, image.translation[0]))
/Users/arve/Dokumenter/git/microscopestitching/microscopestitching/stitching.py:209: UserWarning: Expected images on top of each other to have zero x-offset. r2-c2.png has offset [-59  -2]
  "%s has offset %s" % (image.path, image.translation[0]))
/Users/arve/Dokumenter/git/microscopestitching/microscopestitching/stitching.py:209: UserWarning: Expected images on top of each other to have zero x-offset. r3-c1.png has offset [-56   1]
  "%s has offset %s" % (image.path, image.translation[0]))
/Users/arve/Dokumenter/git/microscopestitching/microscopestitching/stitching.py:209: UserWarning: Expected images on top of each other to have zero x-offset. r3-c2.png has offset [-56   2]
  "%s has offset %s" % (image.path, image.translation[0]))

In [6]:
merged.shape, merged.dtype


Out[6]:
((1874, 1420), dtype('uint8'))

In [7]:
merged.min(), merged.max()


Out[7]:
(0, 222)

In [8]:
imsave('merged.png', merged)
imshow(merged);