_canny.py (scikit-image-0.19.2) | : | _canny.py (scikit-image-0.19.3) | ||
---|---|---|---|---|

skipping to change at line 68 | skipping to change at line 68 | |||

the pixel data that's due to significant points). We then mask the image | the pixel data that's due to significant points). We then mask the image | |||

and apply the function. The resulting values will be lower by the | and apply the function. The resulting values will be lower by the | |||

bleed-over fraction, so you can recalibrate by dividing by the function | bleed-over fraction, so you can recalibrate by dividing by the function | |||

on the mask to recover the effect of smoothing from just the significant | on the mask to recover the effect of smoothing from just the significant | |||

pixels. | pixels. | |||

""" | """ | |||

gaussian_kwargs = dict(sigma=sigma, mode=mode, cval=cval, | gaussian_kwargs = dict(sigma=sigma, mode=mode, cval=cval, | |||

preserve_range=False) | preserve_range=False) | |||

if mask is None: | if mask is None: | |||

# Smooth the masked image | mask = np.ones(image.shape) | |||

smoothed_image = gaussian(image, **gaussian_kwargs) | masked_image = image.copy() | |||

eroded_mask = np.ones(image.shape, dtype=bool) | eroded_mask = np.ones(image.shape, dtype=bool) | |||

eroded_mask[:1, :] = 0 | eroded_mask[:1, :] = 0 | |||

eroded_mask[-1:, :] = 0 | eroded_mask[-1:, :] = 0 | |||

eroded_mask[:, :1] = 0 | eroded_mask[:, :1] = 0 | |||

eroded_mask[:, -1:] = 0 | eroded_mask[:, -1:] = 0 | |||

return smoothed_image, eroded_mask | ||||

masked_image = np.zeros_like(image) | else: | |||

masked_image[mask] = image[mask] | mask = mask.astype(bool, copy=False) | |||

masked_image = np.zeros_like(image) | ||||

masked_image[mask] = image[mask] | ||||

# Make the eroded mask. Setting the border value to zero will wipe | ||||

# out the image edges for us. | ||||

s = ndi.generate_binary_structure(2, 2) | ||||

eroded_mask = ndi.binary_erosion(mask, s, border_value=0) | ||||

# Compute the fractional contribution of masked pixels by applying | # Compute the fractional contribution of masked pixels by applying | |||

# the function to the mask (which gets you the fraction of the | # the function to the mask (which gets you the fraction of the | |||

# pixel data that's due to significant points) | # pixel data that's due to significant points) | |||

bleed_over = ( | bleed_over = gaussian(mask.astype(float, copy=False), | |||

gaussian(mask.astype(float), **gaussian_kwargs) + np.finfo(float).eps | **gaussian_kwargs) + np.finfo(float).eps | |||

) | ||||

# Smooth the masked image | # Smooth the masked image | |||

smoothed_image = gaussian(masked_image, **gaussian_kwargs) | smoothed_image = gaussian(masked_image, **gaussian_kwargs) | |||

# Lower the result by the bleed-over fraction, so you can | # Lower the result by the bleed-over fraction, so you can | |||

# recalibrate by dividing by the function on the mask to recover | # recalibrate by dividing by the function on the mask to recover | |||

# the effect of smoothing from just the significant pixels. | # the effect of smoothing from just the significant pixels. | |||

smoothed_image /= bleed_over | smoothed_image /= bleed_over | |||

# Make the eroded mask. Setting the border value to zero will wipe | ||||

# out the image edges for us. | ||||

s = ndi.generate_binary_structure(2, 2) | ||||

eroded_mask = ndi.binary_erosion(mask, s, border_value=0) | ||||

return smoothed_image, eroded_mask | return smoothed_image, eroded_mask | |||

def _set_local_maxima(magnitude, pts, w_num, w_denum, row_slices, | def _set_local_maxima(magnitude, pts, w_num, w_denum, row_slices, | |||

col_slices, out): | col_slices, out): | |||

"""Get the magnitudes shifted left to make a matrix of the points to | """Get the magnitudes shifted left to make a matrix of the points to | |||

the right of pts. Similarly, shift left and down to get the points | the right of pts. Similarly, shift left and down to get the points | |||

to the top right of pts. | to the top right of pts. | |||

""" | """ | |||

r_0, r_1, r_2, r_3 = row_slices | r_0, r_1, r_2, r_3 = row_slices | |||

c_0, c_1, c_2, c_3 = col_slices | c_0, c_1, c_2, c_3 = col_slices | |||

End of changes. 5 change blocks. | ||||

13 lines changed or deleted | | 14 lines changed or added |