Created
October 18, 2019 15:55
-
-
Save bkj/cacafec84b1a5eb5bdfb1da12edad8e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rle2mask(rle, height, width): | |
rle = [int(xx) for xx in rle.split(' ')] | |
offsets, runs = rle[0::2], rle[1::2] | |
tmp = np.zeros(height * width, dtype=np.uint8) | |
for offset, run in zip(offsets, runs): | |
tmp[offset:offset + run] = 1 | |
return tmp.reshape(width, height).T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment