histo_kit.utils.matlab2python¶
Functions
|
Generate a disk-shaped structuring element (SE) with the given radius. |
|
Get indices of WSI image layers, following MATLAB's iminfo convention. |
|
Convert a Python list to a NumPy array of objects. |
- histo_kit.utils.matlab2python.get_strel_disk(radius)[source]¶
Generate a disk-shaped structuring element (SE) with the given radius.
There are small differences compared to MATLAB’s strel(‘disk’). This implementation was tested for radius values: 3, 4, 5, 7, 8, 9. It gives the same result as MATLAB for 3, 5, and 9, but for 4, 7, and 8 there are minor differences at the corners. The discrepancy arises because MATLAB uses a radial decomposition of the disk, while this function does not.
- Parameters:
radius (int) – Radius of the disk.
- Returns:
SE – Structuring element representing the disk. True values correspond to pixels inside the disk.
- Return type:
ndarray of bool, shape (2*radius-1, 2*radius-1)
Notes
Special case for radius=2 is hard-coded for exact shape.
- histo_kit.utils.matlab2python.get_wsi_ind_matlab(path)[source]¶
Get indices of WSI image layers, following MATLAB’s iminfo convention.
- Parameters:
path (str) – Path to the SVS file containing the WSI image.
- Returns:
indices – Indices of WSI image layers in MATLAB convention (starting from 1).
- Return type:
list of int
Notes
The function converts layer indices to start from 1 to match MATLAB behavior.
- histo_kit.utils.matlab2python.list2cell(list_obj)[source]¶
Convert a Python list to a NumPy array of objects.
- Parameters:
list_obj (list) – List of objects to convert.
- Returns:
cell – NumPy array containing the same objects as in the input list.
- Return type:
ndarray of object, shape (len(list_obj),)
Notes
Each element in the list is preserved as-is in the array.
Useful for interoperability with code expecting NumPy arrays of objects.