extract_collagen_fibers
Extract collagen fibers from a H&E image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img
|
ndarray
|
The input image. Shape (H, W, 3). |
required |
label
|
ndarray
|
Nuclei binary or label mask. Shape (H, W). This is used to mask out the nuclei when extracting collagen fibers. If None, the entire image is used. |
None
|
sigma
|
float
|
The sigma parameter for the Canny edge detector. |
2.5
|
min_size
|
float
|
Minimum size of the edges to keep. |
25
|
rm_bg
|
bool
|
Whether to remove the background component from the edges. |
False
|
rm_fg
|
bool
|
Whether to remove the foreground component from the edges. |
False
|
mask
|
ndarray
|
Binary mask to restrict the region of interest. Shape (H, W). For example, it can be used to mask out tissues that are not of interest. |
None
|
device
|
str
|
Device to use for computation. Options are 'cpu' or 'cuda'. If set to 'cuda', CuPy and cucim will be used for GPU acceleration. |
'cpu'
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The collagen fibers binary mask. Shape (H, W). |
Examples:
>>> from histolytics.data import hgsc_stroma_he
>>> from histolytics.stroma_feats.collagen import extract_collagen_fibers
>>> from skimage.measure import label
>>> from skimage.color import label2rgb
>>> import matplotlib.pyplot as plt
>>>
>>> im = hgsc_stroma_he()
>>> collagen = extract_collagen_fibers(im, label=None, rm_bg=False, rm_fg=False)
>>>
>>> fig, ax = plt.subplots(1, 2, figsize=(8, 4))
>>> ax[0].imshow(label2rgb(label(collagen), bg_label=0))
>>> ax[0].set_axis_off()
>>> ax[1].imshow(im)
>>> ax[1].set_axis_off()
>>> fig.tight_layout()
Source code in src/histolytics/stroma_feats/collagen.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|