fix(v5): preserve grayscale gradient masks
This commit is contained in:
@@ -327,6 +327,7 @@ def gradient_abs_sum(image, params):
|
||||
Use it to emphasize prominent edges before combining them with a sharpened image.
|
||||
"""
|
||||
|
||||
grayscale_input = image.ndim == 2
|
||||
operator = params.get("operator", "sobel")
|
||||
gray = to_gray(image).astype(np.float32)
|
||||
if operator == "roberts":
|
||||
@@ -337,7 +338,8 @@ def gradient_abs_sum(image, params):
|
||||
gy = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]], dtype=np.float32)
|
||||
fx = cv2.filter2D(gray, cv2.CV_32F, gx, borderType=cv2.BORDER_REFLECT)
|
||||
fy = cv2.filter2D(gray, cv2.CV_32F, gy, borderType=cv2.BORDER_REFLECT)
|
||||
return gray_to_rgb(normalize_to_uint8(np.abs(fx) + np.abs(fy)))
|
||||
gradient = normalize_to_uint8(np.abs(fx) + np.abs(fy))
|
||||
return gradient if grayscale_input else gray_to_rgb(gradient)
|
||||
|
||||
|
||||
def rgb_channel(image, params):
|
||||
|
||||
Reference in New Issue
Block a user