Skip to content

Commit

Permalink
Merge pull request #774 from sbrunner/fix-mask-add
Browse files Browse the repository at this point in the history
Fix mask join (auto-mask and file)
  • Loading branch information
sbrunner authored Aug 15, 2022
2 parents 64fc7bb + d6a686a commit 325502f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions scan_to_paperless/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ def _get_mask(
)
if mask_file:
mask = cv2.add(
mask, cv2.bitwise_not(cv2.cvtColor(cv2.imread(mask_file), cv2.COLOR_BGR2GRAY))
mask,
cv2.bitwise_not(
cv2.resize(
cv2.cvtColor(cv2.imread(mask_file), cv2.COLOR_BGR2GRAY),
(mask.shape[1], mask.shape[0]),
)
),
)

final_mask = cv2.bitwise_not(mask)
Expand All @@ -186,10 +192,12 @@ def _get_mask(

final_mask = cv2.imread(mask_file)

maskbw = final_mask if len(final_mask.shape) == 2 else cv2.cvtColor(final_mask, cv2.COLOR_BGR2GRAY)
if self.image is not None and final_mask is not None:
return cast(NpNdarrayInt, cv2.resize(maskbw, (self.image.shape[1], self.image.shape[0])))
return cast(NpNdarrayInt, maskbw)
maskbw = (
final_mask if len(final_mask.shape) == 2 else cv2.cvtColor(final_mask, cv2.COLOR_BGR2GRAY)
)
if self.image is not None and final_mask is not None:
return cast(NpNdarrayInt, cv2.resize(maskbw, (self.image.shape[1], self.image.shape[0])))
return cast(NpNdarrayInt, final_mask)

def init_mask(self) -> None:
"""Init the mask image used to mask the image on the crop and deskew calculation."""
Expand Down

0 comments on commit 325502f

Please # to comment.