haesleinhuepf / git-bob-bioimage-analysis-example

BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Nuclei segmentation #69

Open haesleinhuepf opened 1 month ago

haesleinhuepf commented 1 month ago

This is human_mitosis.png:

human_mitosis

I would like to segment and label the bright nuclei in it, using the Voronoi-Otsu-Labeling algorithm. The resulting label image should be converted to an RGB and saved as .png file.

git-bob think about how to do this with Python.

github-actions[bot] commented 1 month ago

This message was generated by git-bob (version: 0.8.2, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

To address the issue of segmenting and labeling the bright nuclei in human_mitosis.png using the Voronoi-Otsu-Labeling algorithm, you can perform the following steps utilizing Python:

  1. Download the image from the provided URL and save it in the data folder of the repository.
  2. Use the napari-segment-blobs-and-things-with-membranes library for implementing the Voronoi-Otsu-Labeling algorithm.
  3. Convert the resulting label image to an RGB image and save it as a .png file in the data folder.

Here is a Python script proposal for the task:

from skimage.io import imread, imsave
from skimage import color
import napari_segment_blobs_and_things_with_membranes as nsbatwm

# Step 1: Load the image
image_path = 'data/human_mitosis.png'
image = imread(image_path)

# Step 2: Segment the nuclei using Voronoi-Otsu-Labeling
labeled_image = nsbatwm.voronoi_otsu_labeling(image, spot_sigma=3.5, outline_sigma=1)

# Step 3: Convert the label image to RGB
rgb_image = color.label2rgb(labeled_image, bg_label=0)

# Step 4: Save the RGB image
output_path = 'data/human_mitosis_segmented.png'
imsave(output_path, rgb_image)

Please make sure to place the human_mitosis.png image in the data folder before running the script.

haesleinhuepf commented 1 month ago

Ok, great! Create a new jupyter notebook "nuclei_segmentation.ipynb" in the "notebooks" folder. Adapt the relative path to the "data" directory accordingly. Do not forget to download the image from the url I provided initially and store it in the "data" folder. Also make sure that the resulting label image is converted to uint8, before being saved.

git-bob implement this!