Skip to content

Commit

Permalink
Formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aizvorski committed Mar 11, 2015
1 parent 533de66 commit 41ec2df
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ssim.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@

from numpy.lib.stride_tricks import as_strided as ast

# Hat tip: http://stackoverflow.com/a/5078155/1828289
"""
Hat tip: http://stackoverflow.com/a/5078155/1828289
"""
def block_view(A, block=(3, 3)):
"""Provide a 2D block view to 2D array. No error checking made.
Therefore meaningful (as implemented) only for blocks strictly
compatible with the shape of A."""
# simple shape and strides computations may seem at first strange
# unless one is able to recognize the 'tuple additions' involved ;-)
shape= (A.shape[0]/ block[0], A.shape[1]/ block[1])+ block
strides= (block[0]* A.strides[0], block[1]* A.strides[1])+ A.strides
shape = (A.shape[0]/ block[0], A.shape[1]/ block[1])+ block
strides = (block[0]* A.strides[0], block[1]* A.strides[1])+ A.strides
return ast(A, shape= shape, strides= strides)


Expand Down

0 comments on commit 41ec2df

Please sign in to comment.