cellects.simulation.shapes
cellects.simulation.shapes
Generate synthetic binary test images.
Provides utilities to generate binary images or coordinates to generate binary images. It can be either random either deterministic.
Functions:
| Name | Description |
|---|---|
sim_noisy_circle : Create a noisy circular binary image. |
|
random_blob_coord : Sample top‑left coordinates for square blobs. |
|
random_blob_coord(im_size, blob_size, blob_nb)
Generate random top‑left coordinates for a set of square blobs within an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im_size
|
int
|
Size of the (square) image in pixels (height = width = |
required |
blob_size
|
int
|
Edge length of each square blob in pixels. |
required |
blob_nb
|
int
|
Number of blob positions to sample. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
sample_coord |
ndarray
|
|
Notes
The function first builds all possible top‑left positions that keep a full
blob inside the image, mirrors them to include both (y, x) and
(x, y) orientations, and then draws blob_nb unique positions
without replacement.
Examples:
Source code in src/cellects/simulation/shapes.py
sim_noisy_circle(size)
Generate a binary image containing a noisy circular ellipse.
The function creates a solid ellipse, extracts its contour, randomly
removes a subset of contour pixels, and then applies a series of
erosions whose kernel size grows with size. This yields a
disc‑like shape with irregular edges, useful for testing image
processing pipelines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
The height and width of the output square image. Must be a positive integer; larger values produce a smoother overall shape but increase processing time. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
noisy_circle |
NDArray[uint8]
|
A |
Notes
- The erosion kernels are square arrays of ones whose side length is
derived from
log10(size); forsize> 30 two additional directional erosions are applied. - The function relies on OpenCV (
cv2) for the erosion operation.
Examples: