- w, h = topng(join(caspath, dic), '{}/{}-{}'.format(join(OUT_DIR, 'infarctus' if infarctus else 'noinfarctus'), cas, dic))
-
- # search maximums
- if wmax < w: wmax = w
- if hmax < h: hmax = h
-
- # search width minimum
- if wmin is None: wmin = w
- elif wmin > w: wmin = w
-
- # search height minimum
- if hmin is None: hmin = h
- elif hmin > h: hmin = h
-
- print('min-width, max-width:', (wmin, wmax))
- print('min-height, max-height:', (hmin, hmax))
-
- print('Ended!')
+ # print('epimask', epimask)
+
+ if epimask:# this condition could be if necessary
+ # w, h = topng(join(caspath, dic), '{}/{}-{}'.format(join(OUT_DIR, 'infarctus' if infarctus else 'noinfarctus'), cas, dic), epimask=epimask['path'] if epimask else None)
+ # img_, dicimg_, minmax_ = topng(join(caspath, dic),
+ # '{}/{}-{}'.format(join(OUT_DIR, 'infarctus' if infarctus else 'noinfarctus'), cas, dic),
+ # epimask=epimask['path'] if epimask else None,
+ # verbose=True,
+ # )
+
+ # Possibly data augmentation purpose here
+ w, h = topng(
+ join(caspath, dic),
+ outfile='{}/crop-mask/{}-{}'.format(join(OUT_DIR,
+ 'infarctus' if infarctus else 'noinfarctus'),
+ cas,
+ dic,
+ ),
+ epimask=epimask['path'] if epimask else None,
+ centercrop=CROP_SIZE,
+ blackmask=True,
+ ) # crop and mask with black
+
+ if endomask:
+ w, h = topng(
+ join(caspath, dic),
+ outfile='{}/crop-mask-hollow/{}-{}'.format(join(OUT_DIR,
+ 'infarctus' if infarctus else 'noinfarctus'),
+ cas,
+ dic,
+ ),
+ epimask=epimask['path'] if epimask else None,
+ endomask=endomask['path'] if endomask else None,
+ centercrop=CROP_SIZE,
+ blackmask=True,
+ ) # crop and (mask and fill hollow) with black
+
+ w, h = topng(
+ join(caspath, dic),
+ outfile='{}/crop-nomask/{}-{}'.format(join(OUT_DIR,
+ 'infarctus' if infarctus else 'noinfarctus'),
+ cas,
+ dic,
+ ),
+ epimask=epimask['path'] if epimask else None,
+ centercrop=CROP_SIZE,
+ ) # just crop, don't apply black mask
+
+ # w, h = topng(
+ # join(caspath, dic),
+ # outfile='{}/contour/{}-{}'.format(join(OUT_DIR,
+ # 'infarctus' if infarctus else 'noinfarctus'),
+ # cas,
+ # dic,
+ # ),
+ # epimask=epimask['path'] if epimask else None,
+ # redcontour=True,
+ # ) # draw a red contour for visibily purpose
+
+ # segmentation width & height <<
+ # xmin, ymin, xmax, ymax = minmax_
+ # w = xmax - xmin + 1 # +1 : even the position takes a bit
+ # h = ymax - ymin + 1
+ # segmentation width & height >>
+
+
+ # # search maximums
+ # if wmax < w: wmax = w
+ # if hmax < h: hmax = h
+
+ # # search width minimum
+ # if wmin is None: wmin = w
+ # elif wmin > w: wmin = w
+
+ # # search height minimum
+ # if hmin is None: hmin = h
+ # elif hmin > h: hmin = h
+
+
+ # print('min-width, max-width:', (wmin, wmax))
+ # print('min-height, max-height:', (hmin, hmax))
+
+ # print('Ended!')