Skip to content

Commit

Permalink
Add 'TODO' with more info for mask creation
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Feb 24, 2016
1 parent 258115b commit 2c01a57
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/tools/OmeroWeb/omeroweb/webgateway/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ def render_shape_mask(request, shapeId, conn=None, **kwargs):
binarray = numpy.unpackbits(intarray)

# Couldn't get the 'proper' way of doing this to work,
# Maybe look at this again later?
# TODO: look at this again later. Faster than simple way below:
# E.g. takes ~2 seconds for 1984 x 1984 mask
# pixels = ""
# steps = len(binarray) / 8
# for i in range(steps):
Expand All @@ -690,10 +691,11 @@ def render_shape_mask(request, shapeId, conn=None, **kwargs):
# b[5], b[6], b[7])
# for b in binarray:
# pixels += struct.pack("1B", b)
# print 'pixels', repr(pixels)
# im = Image.frombytes("1", size=(4,2), data=pixels)
# im = Image.frombytes("1", size=(width, height), data=pixels)

# Simple approach - Just set each pixel in turn
# E.g. takes ~12 seconds for 1984 x 1984 mask with most pixels '1'
# Or ~5 seconds for same size mask with most pixels "0"
img = Image.new("RGBA", size=(width, height), color=(0, 0, 0, 0))
x = 0
y = 0
Expand Down

0 comments on commit 2c01a57

Please sign in to comment.