ImageProcessing.identify_pixel_edges

giant.image_processing:

ImageProcessing.identify_pixel_edges(image, split_horizontal_vertical=False, return_gradient=False)[source]

This method determines pixel level edges in an image by thresholding the image gradients.

The image gradients are computed by convolving horizontal and vertical Sobel masks with the image to give the horizontal and vertical gradients. The gradient images are then thresholded using otsu() to determine the strongest gradients in the image. The strong gradients are then searched for local maxima, which become the pixel level edges of the image.

This function inputs the image and outputs a binary image with true values corresponding to the edge locations in the image. Optionally, if the split_horizontal_vertical argument is set to True, the 2 binary images are returned, the first with true values in locations containing horizontal edges, and the second with true values in locations containing vertical edges. Finally, if the return_gradient argument is set to true, then the horizontal, vertical, and magnitude gradient arrays are returned as well.

Parameters:
  • image (ndarray) – The image to extract the edges from

  • split_horizontal_vertical (bool) – A flag specifying whether to return the vertical and horizontal edges separately or combined

  • return_gradient (bool) – A flag specifying whether to return the gradient arrays or not

Returns:

the pixel level edges (either as a single boolean array or a split boolean array) and optionally the horizontal, vertical, and magnitude gradient arrays.

Return type:

ndarray | Tuple[ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray, ndarray]