All Projects → Borda → Pyimsegm

Borda / Pyimsegm

Licence: bsd-3-clause
Image segmentation - general superpixel segmentation & center detection & region growing

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pyimsegm

Cvpr2021 Papers With Code
CVPR 2021 论文和开源项目合集
Stars: ✭ 7,138 (+3251.17%)
Mutual labels:  object-detection, image-segmentation, image-processing
Sod
An Embedded Computer Vision & Machine Learning Library (CPU Optimized & IoT Capable)
Stars: ✭ 1,460 (+585.45%)
Mutual labels:  object-detection, image-processing, image-analysis
Segment Open
Segment Source Distribution
Stars: ✭ 34 (-84.04%)
Mutual labels:  image-processing, image-analysis, medical-imaging
Catalyst
Accelerated deep learning R&D
Stars: ✭ 2,804 (+1216.43%)
Mutual labels:  object-detection, image-segmentation, image-processing
Pytorch Toolbelt
PyTorch extensions for fast R&D prototyping and Kaggle farming
Stars: ✭ 942 (+342.25%)
Mutual labels:  object-detection, image-segmentation, image-processing
Albumentations
Fast image augmentation library and an easy-to-use wrapper around other libraries. Documentation: https://albumentations.ai/docs/ Paper about the library: https://www.mdpi.com/2078-2489/11/2/125
Stars: ✭ 9,353 (+4291.08%)
Mutual labels:  object-detection, image-segmentation, image-processing
Kaggle Rsna
Deep Learning for Automatic Pneumonia Detection, RSNA challenge
Stars: ✭ 74 (-65.26%)
Mutual labels:  object-detection, image-processing, medical-imaging
Mirtk
The Medical Image Registration ToolKit (MIRTK), the successor of the IRTK, contains common CMake build configuration files, core libraries, and basic command-line tools. Extension packages are hosted by the MIRTK GitHub group at
Stars: ✭ 119 (-44.13%)
Mutual labels:  image-processing, medical-imaging
Labelbox
Labelbox is the fastest way to annotate data to build and ship computer vision applications.
Stars: ✭ 1,588 (+645.54%)
Mutual labels:  image-segmentation, image-annotation
Color Tracker
Color tracking with OpenCV
Stars: ✭ 128 (-39.91%)
Mutual labels:  object-detection, image-processing
Livianet
This repository contains the code of LiviaNET, a 3D fully convolutional neural network that was employed in our work: "3D fully convolutional networks for subcortical segmentation in MRI: A large-scale study"
Stars: ✭ 143 (-32.86%)
Mutual labels:  image-segmentation, medical-imaging
Make Sense
Free to use online tool for labelling photos. https://makesense.ai
Stars: ✭ 2,087 (+879.81%)
Mutual labels:  object-detection, image-annotation
Open Solution Data Science Bowl 2018
Open solution to the Data Science Bowl 2018
Stars: ✭ 159 (-25.35%)
Mutual labels:  image-processing, medical-imaging
Autoannotationtool
A label tool aim to reduce semantic segmentation label time, rectangle and polygon annotation is supported
Stars: ✭ 113 (-46.95%)
Mutual labels:  image-annotation, image-processing
Mindboggle
Automated anatomical brain label/shape analysis software (+ website)
Stars: ✭ 112 (-47.42%)
Mutual labels:  image-processing, image-analysis
Open Solution Salt Identification
Open solution to the TGS Salt Identification Challenge
Stars: ✭ 124 (-41.78%)
Mutual labels:  image-segmentation, image-processing
Viewers
The OHIF Medical Imaging Viewer is for viewing medical images. It can retrieve and load images from most sources and formats; render sets in 2D, 3D, and reconstructed representations; allows for the manipulation, annotation, and serialization of observations; supports internationalization, OpenID Connect, offline use, hotkeys, and many more features.
Stars: ✭ 1,753 (+723%)
Mutual labels:  image-analysis, medical-imaging
Imageprocessing
MicaSense RedEdge and Altum image processing tutorials
Stars: ✭ 139 (-34.74%)
Mutual labels:  image-processing, image-analysis
Piccante
The hottest High Dynamic Range (HDR) Library
Stars: ✭ 195 (-8.45%)
Mutual labels:  image-segmentation, image-processing
Deepdetect
Deep Learning API and Server in C++14 support for Caffe, Caffe2, PyTorch,TensorRT, Dlib, NCNN, Tensorflow, XGBoost and TSNE
Stars: ✭ 2,306 (+982.63%)
Mutual labels:  object-detection, image-segmentation

Image segmentation toolbox

CI testing codecov Codacy Badge CircleCI CodeFactor Language grade: Python

Documentation Status Gitter CI experiments


Superpixel segmentation with GraphCut regularisation

Image segmentation is widely used as an initial phase of many image processing tasks in computer vision and image analysis. Many recent segmentation methods use superpixels because they reduce the size of the segmentation problem by order of magnitude. Also, features on superpixels are much more robust than features on pixels only. We use spatial regularisation on superpixels to make segmented regions more compact. The segmentation pipeline comprises (i) computation of superpixels; (ii) extraction of descriptors such as colour and texture; (iii) soft classification, using a standard classifier for supervised learning, or the Gaussian Mixture Model for unsupervised learning; (iv) final segmentation using Graph Cut. We use this segmentation pipeline on real-world applications in medical imaging (see sample images. We also show that unsupervised segmentation is sufficient for some situations, and provides similar results to those obtained using trained segmentation.

schema

Sample ipython notebooks:

Illustration

input image segmentation

Reference: Borovec J., Svihlik J., Kybic J., Habart D. (2017). Supervised and unsupervised segmentation using superpixels, model estimation, and Graph Cut. In: Journal of Electronic Imaging.

Object centre detection and Ellipse approximation

An image processing pipeline to detect and localize Drosophila egg chambers that consists of the following steps: (i) superpixel-based image segmentation into relevant tissue classes (see above); (ii) detection of egg center candidates using label histograms and ray features; (iii) clustering of center candidates and; (iv) area-based maximum likelihood ellipse model fitting. See our Poster related to this work.

Sample ipython notebooks:

  • Center detection consists of center candidate training and prediction, and candidate clustering.
  • Ellipse fitting with given estimated center structure segmentation.

Illustration

estimated centres ellipse fitting

Reference: Borovec J., Kybic J., Nava R. (2017) Detection and Localization of Drosophila Egg Chambers in Microscopy Images. In: Machine Learning in Medical Imaging.

Superpixel Region Growing with Shape prior

Region growing is a classical image segmentation method based on hierarchical region aggregation using local similarity rules. Our proposed approach differs from standard region growing in three essential aspects. First, it works on the level of superpixels instead of pixels, which leads to a substantial speedup. Second, our method uses learned statistical shape properties which encourage growing leading to plausible shapes. In particular, we use ray features to describe the object boundary. Third, our method can segment multiple objects and ensure that the segmentations do not overlap. The problem is represented as energy minimisation and is solved either greedily, or iteratively using GraphCuts.

Sample ipython notebooks:

Illustration

growing RG ellipse fitting

Reference: Borovec J., Kybic J., Sugimoto, A. (2017). Region growing using superpixels with learned shape prior. In: Journal of Electronic Imaging.


Installation and configuration

Configure local environment

Create your own local environment, for more see the User Guide, and install dependencies requirements.txt contains list of packages and can be installed as

@duda:~$ cd pyImSegm  
@duda:~/pyImSegm$ virtualenv env
@duda:~/pyImSegm$ source env/bin/activate  
(env)@duda:~/pyImSegm$ pip install -r requirements.txt  
(env)@duda:~/pyImSegm$ python ...

and in the end terminating...

(env)@duda:~/pyImSegm$ deactivate

Compilation

We have implemented cython version of some functions, especially computing descriptors, which require to compile them before using them

python setup.py build_ext --inplace

If loading of compiled descriptors in cython fails, it is automatically swapped to use numpy which gives the same results, but it is significantly slower.

Installation

The package can be installed via pip

pip install git+https://github.com/Borda/pyImSegm.git

or using setuptools from a local folder

python setup.py install

Experiments

Short description of our three sets of experiments that together compose single image processing pipeline in this order:

  1. Semantic (un/semi)supervised segmentation
  2. Center detection and ellipse fitting
  3. Region growing with the learned shape prior

Annotation tools

We introduce some useful tools for work with image annotation and segmentation.

  • Quantization: in case you have some smooth colour labelling in your images you can remove them with following quantisation script.
    python handling_annotations/run_image_color_quantization.py \
        -imgs "./data-images/drosophila_ovary_slice/segm_rgb/*.png" \
        -m position -thr 0.01 --nb_workers 2
    
  • Paint labels: concerting image labels into colour space and other way around.
    python handling_annotations/run_image_convert_label_color.py \
        -imgs "./data-images/drosophila_ovary_slice/segm/*.png" \
        -out ./data-images/drosophila_ovary_slice/segm_rgb
    
  • Visualisation: having input image and its segmentation we can use simple visualisation which overlap the segmentation over input image.
    python handling_annotations/run_overlap_images_segms.py \
        -imgs "./data-images/drosophila_ovary_slice/image/*.jpg" \
        -segs ./data-images/drosophila_ovary_slice/segm \
        -out ./results/overlap_ovary_segment
    
  • In-painting selected labels in segmentation.
    python handling_annotations/run_segm_annot_inpaint.py \
        -imgs "./data-images/drosophila_ovary_slice/segm/*.png" \
        --label 4
    
  • Replace labels: change labels in input segmentation into another set of labels in 1:1 schema.
    python handling_annotations/run_segm_annot_relabel.py \
        -out ./results/relabel_center_levels \
        --label_old 2 3 --label_new 1 1 
    

Semantic (un/semi)supervised segmentation

We utilise (un)supervised segmentation according to given training examples or some expectations. vusial debug

  • Evaluate superpixels (with given SLIC parameters) quality against given segmentation. It helps to find out the best SLIC configuration.
    python experiments_segmentation/run_eval_superpixels.py \
        -imgs "./data-images/drosophila_ovary_slice/image/*.jpg" \
        -segm "./data-images/drosophila_ovary_slice/annot_eggs/*.png" \
        --img_type 2d_split \
        --slic_size 20 --slic_regul 0.25 --slico
    
  • Perform Un-Supervised segmentation in images given in CSV
    python experiments_segmentation/run_segm_slic_model_graphcut.py \
       -l ./data-images/langerhans_islets/list_lang-isl_imgs-annot.csv -i "" \
       -cfg experiments_segmentation/sample_config.yml \
       -o ./results -n langIsl --nb_classes 3 --visual --nb_workers 2
    
    OR specified on particular path:
    python experiments_segmentation/run_segm_slic_model_graphcut.py \
       -l "" -i "./data-images/langerhans_islets/image/*.jpg" \
       -cfg ./experiments_segmentation/sample_config.yml \
       -o ./results -n langIsl --nb_classes 3 --visual --nb_workers 2
    
    unsupervised
  • Perform Supervised segmentation with afterwards evaluation.
    python experiments_segmentation/run_segm_slic_classif_graphcut.py \
        -l ./data-images/drosophila_ovary_slice/list_imgs-annot-struct.csv \
        -i "./data-images/drosophila_ovary_slice/image/*.jpg" \
        --path_config ./experiments_segmentation/sample_config.yml \
        -o ./results -n Ovary --img_type 2d_split --visual --nb_workers 2
    
    supervised
  • Perform Semi-Supervised is using the the supervised pipeline with not fully annotated images.
  • For both experiment you can evaluate segmentation results.
    python experiments_segmentation/run_compute-stat_annot-segm.py \
        -a "./data-images/drosophila_ovary_slice/annot_struct/*.png" \
        -s "./results/experiment_segm-supervise_ovary/*.png" \
        -i "./data-images/drosophila_ovary_slice/image/*.jpg" \
        -o ./results/evaluation --visual
    
    vusial

The previous two (un)segmentation accept configuration file (YAML) by parameter -cfg with some extra parameters which was not passed in arguments, for instance:

slic_size: 35
slic_regul: 0.2
features: 
  color_hsv: ['mean', 'std', 'eng']
classif: 'SVM'
nb_classif_search: 150
gc_edge_type: 'model'
gc_regul: 3.0
run_LOO: false
run_LPO: true
cross_val: 0.1

Center detection and ellipse fitting

In general, the input is a formatted list (CSV file) of input images and annotations. Another option is set by -list none and then the list is paired with given paths to images and annotations.

Experiment sequence is the following:

  1. We can create the annotation completely manually or use the following script which uses annotation of individual objects and create the zones automatically.
    python experiments_ovary_centres/run_create_annotation.py
    
  2. With zone annotation, we train a classifier for centre candidate prediction. The annotation can be a CSV file with annotated centres as points, and the zone of positive examples is set uniformly as the circular neighbourhood around these points. Another way (preferable) is to use an annotated image with marked zones for positive, negative and neutral examples.
    python experiments_ovary_centres/run_center_candidate_training.py -list none \
        -segs "./data-images/drosophila_ovary_slice/segm/*.png" \
        -imgs "./data-images/drosophila_ovary_slice/image/*.jpg" \
        -centers "./data-images/drosophila_ovary_slice/center_levels/*.png" \
        -out ./results -n ovary
    
  3. Having trained classifier we perform center prediction composed from two steps: i) center candidate clustering and ii) candidate clustering.
    python experiments_ovary_centres/run_center_prediction.py -list none \
        -segs "./data-images/drosophila_ovary_slice/segm/*.png" \
        -imgs "./data-images/drosophila_ovary_slice/image/*.jpg" \
        -centers ./results/detect-centers-train_ovary/classifier_RandForest.pkl \
        -out ./results -n ovary
    
  4. Assuming you have an expert annotation you can compute static such as missed eggs.
    python experiments_ovary_centres/run_center_evaluation.py
    
  5. This is just cut out clustering in case you want to use different parameters.
    python experiments_ovary_centres/run_center_clustering.py \
        -segs "./data-images/drosophila_ovary_slice/segm/*.png" \
        -imgs "./data-images/drosophila_ovary_slice/image/*.jpg" \
        -centers "./results/detect-centers-train_ovary/candidates/*.csv" \
        -out ./results
    
  6. Matching the ellipses to the user annotation.
    python experiments_ovary_detect/run_ellipse_annot_match.py \
        -info "~/Medical-drosophila/all_ovary_image_info_for_prague.txt" \
        -ells "~/Medical-drosophila/RESULTS/3_ellipse_ransac_crit_params/*.csv" \
        -out ~/Medical-drosophila/RESULTS
    
  7. Cut eggs by stages and norm to mean size.
    python experiments_ovary_detect/run_ellipse_cut_scale.py \
        -info ~/Medical-drosophila/RESULTS/info_ovary_images_ellipses.csv \
        -imgs "~/Medical-drosophila/RESULTS/0_input_images_png/*.png" \
        -out ~/Medical-drosophila/RESULTS/images_cut_ellipse_stages
    
  8. Rotate (swap) extracted eggs according the larger mount of mass.
    python experiments_ovary_detect/run_egg_swap_orientation.py \
        -imgs "~/Medical-drosophila/RESULTS/atlas_datasets/ovary_images/stage_3/*.png" \
        -out ~/Medical-drosophila/RESULTS/atlas_datasets/ovary_images/stage_3
    

ellipse fitting

Region growing with a shape prior

In case you do not have estimated object centres, you can use plugins for landmarks import/export for Fiji.

Note: install the multi-snake package which is used in multi-method segmentation experiment.

pip install --user git+https://github.com/Borda/morph-snakes.git

Experiment sequence is the following:

  1. Estimating the shape model from set training images containing a single egg annotation.
    python experiments_ovary_detect/run_RG2Sp_estim_shape-models.py  \
        -annot "~/Medical-drosophila/egg_segmentation/mask_2d_slice_complete_ind_egg/*.png" \
        -out ./data-images -nb 15
    
  2. Run several segmentation techniques on each image.
    python experiments_ovary_detect/run_ovary_egg-segmentation.py  \
        -list ./data-images/drosophila_ovary_slice/list_imgs-segm-center-points.csv \
        -out ./results -n ovary_image --nb_workers 1 \
        -m ellipse_moments \
           ellipse_ransac_mmt \
           ellipse_ransac_crit \
           GC_pixels-large \
           GC_pixels-shape \
           GC_slic-large \
           GC_slic-shape \
           rg2sp_greedy-mixture \
           rg2sp_GC-mixture \
           watershed_morph
    
  3. Evaluate your segmentation ./results to expert annotation.
    python experiments_ovary_detect/run_ovary_segm_evaluation.py --visual
    
  4. In the end, cut individual segmented objects comes as minimal bounding box.
    python experiments_ovary_detect/run_cut_segmented_objects.py \
        -annot "./data-images/drosophila_ovary_slice/annot_eggs/*.png" \
        -img "./data-images/drosophila_ovary_slice/segm/*.png" \
        -out ./results/cut_images --padding 50
    
  5. Finally, performing visualisation of segmentation results together with expert annotation.
    python experiments_ovary_detect/run_export_user-annot-segm.py
    
    user-annnot

References

For complete references see BibTex.

  1. Borovec J., Svihlik J., Kybic J., Habart D. (2017). Supervised and unsupervised segmentation using superpixels, model estimation, and Graph Cut. SPIE Journal of Electronic Imaging 26(6), 061610. DOI: 10.1117/1.JEI.26.6.061610.
  2. Borovec J., Kybic J., Nava R. (2017) Detection and Localization of Drosophila Egg Chambers in Microscopy Images. In: Wang Q., Shi Y., Suk HI., Suzuki K. (eds) Machine Learning in Medical Imaging. MLMI 2017. LNCS, vol 10541. Springer, Cham. DOI: 10.1007/978-3-319-67389-9_3.
  3. Borovec J., Kybic J., Sugimoto, A. (2017). Region growing using superpixels with learned shape prior. SPIE Journal of Electronic Imaging 26(6), 061611. DOI: 10.1117/1.JEI.26.6.061611.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].