Skip to content

Commit 5500353

Browse files
committed
fix global superpixel tracker
1 parent 64a2ed7 commit 5500353

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

histomicstk/cli/SuperpixelSegmentation/SuperpixelSegmentation.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,25 +125,14 @@ def createSuperPixelsParallel(opts):
125125
if hasattr(opts, 'callback'):
126126
opts.callback('file', 0, 2 if opts.outputAnnotationFile else 1)
127127

128-
found = 0
129-
bboxes = []
130-
bboxesUser = []
131-
for cx, cy in grid:
132-
133-
stripidx = (coordx[cx], cy)
134-
found += strips_found[stripidx]
135-
bboxes += bboxes_dict[stripidx]
136-
bboxesUser += bboxesUser_dict[stripidx]
137-
138-
print('>> Found %d superpixels' % found)
139-
if found > 256 ** 3:
140-
print('Too many superpixels')
141128
img = pyvips.Image.black(
142129
tiparams.get('region', {}).get('width', meta['sizeX']) / scale,
143130
tiparams.get('region', {}).get('height', meta['sizeY']) / scale,
144131
bands=4)
145132
img = img.copy(interpretation=pyvips.Interpretation.RGB)
146133

134+
135+
found = 0
147136
for cx, cy in grid:
148137

149138
stripidx = (coordx[cx], cy)
@@ -169,6 +158,7 @@ def createSuperPixelsParallel(opts):
169158

170159
img = img.composite([vimg], pyvips.BlendMode.OVER, x=stripidx[0], y=int(strips[stripidx][0]))
171160

161+
found += strips_found[stripidx]
172162

173163

174164
# Discard alpha band, if any.
@@ -187,6 +177,19 @@ def createSuperPixelsParallel(opts):
187177
# region_shrink=pyvips.RegionShrink.MAX,
188178
bigtiff=True, compression='lzw', predictor='horizontal')
189179

180+
bboxes = []
181+
bboxesUser = []
182+
for cx, cy in grid:
183+
184+
stripidx = (coordx[cx], cy)
185+
bboxes += bboxes_dict[stripidx]
186+
bboxesUser += bboxesUser_dict[stripidx]
187+
188+
print('>> Found %d superpixels' % found)
189+
if found > 256 ** 3:
190+
print('Too many superpixels')
191+
192+
190193
if hasattr(opts, 'callback'):
191194
opts.callback('file', 1, 2 if opts.outputAnnotationFile else 1)
192195
if opts.outputAnnotationFile:

0 commit comments

Comments
 (0)