eyepy.core.grids
circle_mask(radius, mask_shape=None, smooth_edges=False)
Create a centered circular mask with given radius.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius |
int
|
|
required |
mask_shape |
Optional[tuple[int, int]]
|
|
None
|
smooth_edges |
bool
|
|
False
|
Returns:
Source code in src/eyepy/core/grids.py
create_grid_regions(mask_shape, radii, n_sectors, offsets, clockwise, smooth_edges=False)
cached
Create sectorized circular region masks.
First circular masks with the provided radii are generated. Then ring masks
are created by subtracting the first circular mask from the second and so
on.
If you want the complete ring, set the respective n_sectors entry to 1. You can split
the ring into n sectors by setting the respective entry to n.
Setting a number in offsets
rotates the respective ring sectors by n
degree.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask_shape |
tuple[int, int]
|
Output shape of the computed masks |
required |
radii |
Sequence[int]
|
Ascending radii of the circular regions in pixels |
required |
n_sectors |
Sequence[int]
|
Number of sectors corresponding to the radii |
required |
offsets |
Sequence[int]
|
Angular offset of first sector corresponding to the radii |
required |
clockwise |
bool
|
If True sectors are added clockwise starting from the start_angles |
required |
smooth_edges |
bool
|
If True, compute non binary masks where edges might be shared between adjacent regions |
False
|
Returns:
Source code in src/eyepy/core/grids.py
create_sectors(mask_shape, n_sectors=4, start_angle=0, clockwise=False, smooth_edges=False)
Create masks for n radial sectors.
By default the first sector is the first quadrant, and the remaining 3 sectors are added counter clockwise.
For a binary mask pixels can not belong to two mask without changing the sum over all masks. But for pixels at the sector edges it is not clear to which sector they belong and assigning them to two sectors partially might be desired. Hence if smooth_edges is True, we create 5 times bigger binary masks and then use the anti-aliasing from downscaling them to the desired shape to create a float mask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask_shape |
tuple[int, int]
|
|
required |
n_sectors |
int
|
|
4
|
start_angle |
int
|
|
0
|
clockwise |
bool
|
|
False
|
smooth_edges |
bool
|
|
False
|
Returns:
Source code in src/eyepy/core/grids.py
filtergrid(size, quadrant_shift=True, normalize=True)
cached
Generates grid for constructing frequency domain filters.
Coordinate matrices for x and y value for a 2D array. The out can be quadrant shifted and / or normalized. This is basically a wrapper around np.meshgrid.
Inspired by filtergrid.m found at https://www.peterkovesi.com/matlabfns/
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
Shape
|
Size of the filter |
required |
quadrant_shift |
bool
|
Quadrant shift such that 0 values / frequencies are at the corners |
True
|
normalize |
bool
|
Normalize the range to [-0.5,0.5] |
True
|
Returns:
Source code in src/eyepy/core/grids.py
grid(mask_shape, radii, laterality, n_sectors=1, offsets=0, center=None, smooth_edges=False, radii_scale=1)
Create a quantification grid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask_shape |
tuple[int, int]
|
Output shape of the computed masks |
required |
radii |
Union[Sequence[Union[int, float]], int, float]
|
Ascending radii of the circular regions in pixels |
required |
laterality |
str
|
OD/OS depending for which eye to compute the grid |
required |
n_sectors |
Union[Sequence[Union[int, float]], int, float]
|
Number of sectors corresponding to the radii |
1
|
offsets |
Union[Sequence[Union[int, float]], int, float]
|
Sector offsets from the horizonal line on the nasal side in degree |
0
|
center |
Optional[tuple]
|
Center location of the computed masks |
None
|
smooth_edges |
bool
|
If True, compute non binary masks where edges might be shared between adjacent regions |
False
|
radii_scale |
Union[int, float]
|
|
1
|
Returns:
Source code in src/eyepy/core/grids.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
radius_filtergrid(size, quadrant_shift=True, normalize=True)
cached
Radius Filtergrid.
A matrix containing the radius from the center. This radius is in range [0, 0.5] if normalized. The result can be quadrant shifted such that the 0 values are in the corners.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
Shape
|
Size of the filter |
required |
quadrant_shift |
bool
|
Quadrant shift such that 0 values / frequencies are at the corners |
True
|
normalize |
bool
|
Normalize radius to [0 ,0.5] |
True
|
Returns:
Source code in src/eyepy/core/grids.py
theta_filtergrid(size, quadrant_shift=True)
cached
Theta Filtergrid.
A matrix containing the polar angle in radian at the respective position for a circle centered in the matrix. The result can be returned quadrant shifted. The angle is 0 for all points on the positive x-axis. The angles are pi/2 (90°) and -pi/2 (-90°) on the positive and negative y-axis respectively. On the negative x-axis the angle is pi (180°). If you need the angle to be in range [0, 2pi] instead of [-pi, pi], you can simply add 2pi whenever the angle is negative.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
Shape
|
Size of the filter |
required |
quadrant_shift |
bool
|
Quadrant shift such that 0 values / frequencies are at the corners |
True
|
Returns: