Skip to content
Snippets Groups Projects
Commit 2293f0ea authored by s204159's avatar s204159 :sunglasses: Committed by fima
Browse files

Cc documentation

parent f4715d16
Branches
Tags
1 merge request!72Cc documentation
docs/assets/screenshots/plot_cc_no_overlay.png

4.46 KiB

docs/assets/screenshots/plot_cc_overlay.png

6.65 KiB

......@@ -9,16 +9,22 @@ As the library is still in its early development stages, **there may be breaking
And remember to keep your pip installation [up to date](/qim3d/#upgrade) so that you have the latest features!
### v0.3.4 (coming soon!)
- Documentation for `qim3d.viz.plot_cc`
### v0.3.3 (11/04/2024)
- Introduction of `qim3d.viz.slicer` (and also `qim3d.viz.orthogonal` ) 🎉
- Introduction of `qim3d.gui.annotation_tool` 🎉
- Introduction of `qim3d.processing.Blob` for blob detection 🎉
- Introduction of `qim3d.processing.local_thickness` 🎉
- Introduction of `qim3d.processing.structure_tensor` 🎉
- Support for loading DICOM files with `qim3d.io.load`🎉
- Support for loading DICOM files with `qim3d.io.load`
- Introduction of `qim3d.processing.get_3d_cc` for 3D connected components and `qim3d.viz.plot_cc` for associated visualization 🎉
- Introduction of `qim3d.viz.colormaps` for easy visualization of e.g. multi-label segmentation results 🎉
- Introduction of `qim3d.processing.operations.background_removal` 🎉
- Documentation refactoring
- Fixed bug preventing `Data Explorer` to show files
### v0.3.2 (23/02/2024)
......
......@@ -97,3 +97,7 @@ code {
.md-typeset .admonition.example, .md-typeset details.example {
border-color: #ff9900;
}
.md-typeset .example>.admonition-title:after, .md-typeset .example>summary:after {
color: #ff9900;
}
\ No newline at end of file
......@@ -72,7 +72,7 @@ class CC:
def get_3d_cc(image: np.ndarray | torch.Tensor) -> CC:
""" Get the connected components of a 3D volume.
""" Returns an object (CC) containing the connected components of the input volume. Use plot_cc to visualize the connected components.
Args:
image (np.ndarray | torch.Tensor): An array-like object to be labeled. Any non-zero values in `input` are
......@@ -80,8 +80,14 @@ def get_3d_cc(image: np.ndarray | torch.Tensor) -> CC:
Returns:
CC: A ConnectedComponents object containing the connected components and the number of connected components.
Example:
```python
import qim3d
vol = qim3d.examples.cement_128x128x128[50:150]<60
cc = qim3d.processing.get_3d_cc(vol)
```
"""
connected_components, num_connected_components = label(image)
log.info(f"Total number of connected components found: {num_connected_components}")
return CC(connected_components, num_connected_components)
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
from qim3d.io.logger import log
from qim3d.processing.cc import CC
from qim3d.viz import slices
from qim3d.viz.colormaps import objects as qim3dCmap
from qim3d.processing.cc import CC
def plot_cc(
connected_components,
......@@ -14,11 +17,11 @@ def plot_cc(
**kwargs,
) -> list[plt.Figure]:
"""
Plot the connected components of an image.
Plots the connected components from a `qim3d.processing.cc.CC` object. If an overlay image is provided, the connected component will be masked to the overlay image.
Parameters:
connected_components (CC): The connected components object.
components (list | tuple, optional): The components to plot. If None the first max_cc_to_plot=32 components will be plotted. Defaults to None.
component_indexs (list | tuple, optional): The components to plot. If None the first max_cc_to_plot=32 components will be plotted. Defaults to None.
max_cc_to_plot (int, optional): The maximum number of connected components to plot. Defaults to 32.
overlay (optional): Overlay image. Defaults to None.
crop (bool, optional): Whether to crop the image to the cc. Defaults to False.
......@@ -27,6 +30,18 @@ def plot_cc(
Returns:
figs (list[plt.Figure]): List of figures, if `show=False`.
Example:
```python
import qim3d
vol = qim3d.examples.cement_128x128x128[50:150]
vol_bin = vol<80
cc = qim3d.processing.get_3d_cc(vol_bin)
qim3d.viz.plot_cc(cc, crop=True, show=True, overlay=None, n_slices=5, component_indexs=[4,6,7])
qim3d.viz.plot_cc(cc, crop=True, show=True, overlay=vol, n_slices=5, component_indexs=[4,6,7])
```
![plot_cc_no_overlay](assets/screenshots/plot_cc_no_overlay.png)
![plot_cc_overlay](assets/screenshots/plot_cc_overlay.png)
"""
# if no components are given, plot the first max_cc_to_plot=32 components
if component_indexs is None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment