MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / get_descriptors

Function get_descriptors

computer_vision/haralick_descriptors.py:313–335  ·  view source on GitHub ↗

Calculate all Haralick descriptors for a sequence of different co-occurrence matrices, given input masks and coordinates. Example: >>> img = np.array([[[108, 201, 72], [255, 11, 127]], ... [[56, 56, 56], [128, 255, 107]]]) >>> gray = grayscale

(
    masks: tuple[np.ndarray, np.ndarray], coordinate: tuple[int, int]
)

Source from the content-addressed store, hash-verified

311
312
313def get_descriptors(
314 masks: tuple[np.ndarray, np.ndarray], coordinate: tuple[int, int]
315) -> np.ndarray:
316 """
317 Calculate all Haralick descriptors for a sequence of
318 different co-occurrence matrices, given input masks and coordinates.
319
320 Example:
321 >>> img = np.array([[[108, 201, 72], [255, 11, 127]],
322 ... [[56, 56, 56], [128, 255, 107]]])
323 >>> gray = grayscale(img)
324 >>> binary = binarize(gray)
325 >>> morphological = opening_filter(binary)
326 >>> get_descriptors(binary_mask(gray, morphological), (0, 1))
327 array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
328 """
329 descriptors = np.array(
330 [haralick_descriptors(matrix_concurrency(mask, coordinate)) for mask in masks]
331 )
332
333 # Concatenate each individual descriptor into
334 # one single list containing sequence of descriptors
335 return np.concatenate(descriptors, axis=None)
336
337
338def euclidean(point_1: np.ndarray, point_2: np.ndarray) -> float:

Callers 1

Calls 2

haralick_descriptorsFunction · 0.85
matrix_concurrencyFunction · 0.85

Tested by

no test coverage detected