hvala kurcu zdej tuji stekam zakaj je prej dello k nei smelo
parent
4c03725812
commit
11d0519132
|
@ -190,7 +190,7 @@ def two_b():
|
|||
derivative magnitude). You only need to compute the comparison to actual pixels,
|
||||
interpolating to more accuracy is not required.
|
||||
"""
|
||||
SIGMA = 0.2
|
||||
SIGMA = 0.5
|
||||
THETA = 0.16
|
||||
|
||||
museum = uz_image.imread_gray('./images/museum.jpg', uz_image.ImageType.float64)
|
||||
|
|
|
@ -596,27 +596,19 @@ def find_edges_nms(image: Union[npt.NDArray[np.float64], npt.NDArray[np.uint8]],
|
|||
return (-1, -1), (1, 1)
|
||||
raise ValueError(f"Angle {angle} is not in range")
|
||||
|
||||
|
||||
derivative_magnitude, derivative_angles = gradient_magnitude(image, sigma)
|
||||
|
||||
reduced_magnitude = np.zeros_like(derivative_magnitude)
|
||||
nms_mask = np.zeros_like(derivative_magnitude)
|
||||
reduced_magnitude[(derivative_magnitude >= theta)] = 1
|
||||
#reduced_magnitude = np.zeros_like(derivative_magnitude)
|
||||
reduced_magnitude = derivative_magnitude.copy()
|
||||
reduced_magnitude[(derivative_magnitude <= theta)] = 0
|
||||
|
||||
|
||||
for y in range(reduced_magnitude.shape[0]):
|
||||
for x in range(reduced_magnitude.shape[1]):
|
||||
for y in range(1, reduced_magnitude.shape[0]-1):
|
||||
for x in range(1, reduced_magnitude.shape[1]-1):
|
||||
gp1, gp2 = get_gradient_orientation(derivative_angles[y, x])
|
||||
|
||||
# Out of bounds checks
|
||||
if x + gp1[0] < 0 or x + gp2[0] < 0:
|
||||
continue
|
||||
elif y + gp1[1] < 0 or y + gp2[1] < 0:
|
||||
continue
|
||||
elif x + gp1[0] >= reduced_magnitude.shape[1] or x + gp2[0] >= reduced_magnitude.shape[1]:
|
||||
continue
|
||||
elif y + gp1[1] >= reduced_magnitude.shape[0] or y + gp2[1] >= reduced_magnitude.shape[0]:
|
||||
continue
|
||||
elif reduced_magnitude[y + gp1[1], x + gp1[0]] == 1 and reduced_magnitude[y + gp2[1], x + gp2[0]] == 1:
|
||||
nms_mask[y, x] = 1
|
||||
if reduced_magnitude[y, x] < reduced_magnitude[y+gp1[0], x+gp1[1]] or reduced_magnitude[y, x] < reduced_magnitude[y+gp2[0], x+gp2[1]]:
|
||||
reduced_magnitude[y, x] = 0
|
||||
|
||||
return nms_mask
|
||||
return reduced_magnitude
|
||||
|
|
Loading…
Reference in New Issue