Skip to content

Commit

Permalink
fix: broken final exclusion mask
Browse files Browse the repository at this point in the history
  • Loading branch information
OBrink committed Dec 7, 2023
1 parent 8143111 commit 1f6a8d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions decimer_segmentation/complete_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ def complete_structure_mask(
if mask_array.size != 0:
# Binarization of input image
binarized_image_array = binarize_image(image_array, threshold=0.72)
debug = True
if debug:
plot_it(binarized_image_array)
# Apply dilation with a resolution-dependent kernel to the image
blur_factor = (
int(image_array.shape[1] / 185) if image_array.shape[1] / 185 >= 2 else 2
Expand All @@ -287,9 +290,6 @@ def complete_structure_mask(
blurred_image_array = binary_erosion(binarized_image_array, footprint=kernel)
if debug:
plot_it(blurred_image_array)
debug = True
if debug:
plot_it(binarized_image_array)
# Slice mask array along third dimension into single masks
split_mask_arrays = np.array(
[mask_array[:, :, index] for index in range(mask_array.shape[2])]
Expand All @@ -306,13 +306,14 @@ def complete_structure_mask(
)
hough_lines = binary_dilation(hough_lines, footprint=kernel)
exclusion_mask = horizontal_vertical_lines + hough_lines
image_with_exclusion = np.invert(
np.invert(blurred_image_array) * np.invert(exclusion_mask)
)
if debug:
plot_it(horizontal_vertical_lines)
plot_it(hough_lines)
plot_it(exclusion_mask)
plot_it(np.invert(binarized_image_array) * np.invert(exclusion_mask))
image_with_exclusion = np.invert(blurred_image_array) * np.invert(exclusion_mask)

plot_it(image_with_exclusion)
# Run expansion
image_repeat = itertools.repeat(image_with_exclusion, mask_array.shape[2])
exclusion_repeat = itertools.repeat(exclusion_mask, mask_array.shape[2])
Expand Down
4 changes: 2 additions & 2 deletions decimer_segmentation/decimer_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ def determine_depiction_size_with_buffer(
width = bbox[3] - bbox[1]
heights.append(height)
widths.append(width)
height = int(1.05 * np.max(heights))
width = int(1.05 * np.max(widths))
height = int(1.1 * np.max(heights))
width = int(1.1 * np.max(widths))
return height, width


Expand Down

0 comments on commit 1f6a8d9

Please sign in to comment.