Skip to content

Commit

Permalink
preprocess sample image
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Aug 14, 2015
1 parent f3c5340 commit 1f08bc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions dask/array/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def imread(filename, imread=None, preprocess=None):
name = 'imread-%s' % tokenize(filenames, map(os.path.getmtime, filenames))

sample = imread(filenames[0])
if preprocess:
sample = preprocess(sample)

keys = [(name, i) + (0,) * len(sample.shape) for i in range(len(filenames))]
if preprocess:
Expand Down
4 changes: 2 additions & 2 deletions dask/array/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def imread2(fn):
def test_preprocess():
def preprocess(x):
x[:] = 1
return x
return x[:, :, 0]
with random_images(4, (2, 3, 4)) as globstring:
im = da_imread(globstring, preprocess=preprocess)
assert (im.compute() == np.ones((4, 2, 3, 4), dtype='i1')).all()
assert (im.compute() == np.ones((4, 2, 3), dtype='i1')).all()

0 comments on commit 1f08bc2

Please sign in to comment.