Skip to content
Snippets Groups Projects
Commit 711721ec authored by Hugo CHAUVET's avatar Hugo CHAUVET :bicyclist:
Browse files

Fix bug when darkofwhite is cropped and not white

parent 8deab784
Branches
No related tags found
No related merge requests found
......@@ -280,8 +280,9 @@ def process_white(implus_white, implus_darkofwhite, zofwhite, roi=None):
img_white = IL.wrap(implus_white)
img_dark = IL.wrap(implus_darkofwhite)
# Do we need to crop
# Do we need to crop white
if roi is not None and len(roi) == 4 and implus_white.width > roi[2] and implus_white.height > roi[3]:
print('I crop the white')
xmin, ymin, xmax, ymax = roi
xmax = xmin + xmax
ymax = ymin + ymax
......@@ -291,13 +292,39 @@ def process_white(implus_white, implus_darkofwhite, zofwhite, roi=None):
ymax = implus_white.height
# Select the chanel
img_whiteC = Views.interval(Views.hyperSlice(img_white, 2, zofwhite-1),
Intervals.createMinMax(xmin, ymin,
xmax-1, ymax-1))
img_darkC = Views.interval(img_dark,
Intervals.createMinMax(xmin, ymin,
xmax-1, ymax-1))
#img_whiteC = Views.interval(Views.hyperSlice(img_white, 2, zofwhite-1),
# Intervals.createMinMax(xmin, ymin,
# xmax-1, ymax-1))
# The above command does not crop correctly when darkofwhite and white does
# not share the same size
img_whiteC = ops.run("transform.crop", Views.hyperSlice(img_white, 2, zofwhite-1),
Intervals.createMinMax(xmin, ymin, xmax-1, ymax-1), True)
# Do we need to crop Dark
if roi is not None and len(roi) == 4 and implus_darkofwhite.width > roi[2] and implus_darkofwhite.height > roi[3]:
print('I crop the Dark of White')
xmin, ymin, xmax, ymax = roi
xmax = xmin + xmax
ymax = ymin + ymax
else:
xmin = ymin = 0
xmax = implus_darkofwhite.width
ymax = implus_darkofwhite.height
#img_darkC = Views.interval(img_dark,
# Intervals.createMinMax(xmin, ymin,
# xmax-1, ymax-1))
# The above command does not crop correctly when darkofwhite and white does
# not share the same size
img_darkC = ops.run("transform.crop", img_dark,
Intervals.createMinMax(xmin, ymin,xmax-1, ymax-1),
True)
# IL.show(img_whiteC)
# IL.show(img_darkC)
# Get min max values
minwhite = float(ops.run("stats.min", img_whiteC).toString())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment