Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
update segmentations (#6)
Browse files Browse the repository at this point in the history
 * rename internal function
 * update manifest
 * rename local _wrapper
 * code cleaning
 * unify segm. models
 * move images -> data_images
 * add Langer. islets images
 * optionally missing params
 * add using segm. config
 * update annots
 * fix segm. debug show
 * check segm. features
 * regroup general images
 * update colors for visual @segm
 * update arg params @segm
 * add label boundary
 * fix classif. stat
 * add unsuper. model
 * update (c)
 * add mv Otsu threshold
 * update compute stat @segm
 * add color mGrad
 * update doc
  • Loading branch information
Borda authored Apr 12, 2018
1 parent 80b0e28 commit d1da652
Show file tree
Hide file tree
Showing 199 changed files with 1,115 additions and 761 deletions.
16 changes: 8 additions & 8 deletions .shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ script:
- nosetests -v --exe --with-doctest --with-xunit --with-coverage --cover-package=imsegm --xunit-file=$CI_REPORTS/nosetests.xml

# ANNOTATION section
- python handling_annotations/run_image_color_quantization.py -imgs "images/drosophila_ovary_slice/segm_rgb/*.png"
- python handling_annotations/run_image_convert_label_color.py -imgs "images/drosophila_ovary_slice/segm/*.png" -out images/drosophila_ovary_slice/segm_rgb
- python handling_annotations/run_overlap_images_segms.py -imgs "images/drosophila_ovary_slice/image/*.jpg" -segs images/drosophila_ovary_slice/segm -out results/overlap_ovary_segment
- python handling_annotations/run_segm_annot_inpaint.py -imgs "images/drosophila_ovary_slice/segm/*.png" --label 0
- python handling_annotations/run_segm_annot_relabel.py -imgs "images/drosophila_ovary_slice/center_levels/*.png" -out results/relabel_center_levels
- python handling_annotations/run_image_color_quantization.py -imgs "data_images/drosophila_ovary_slice/segm_rgb/*.png"
- 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
- 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
- python handling_annotations/run_segm_annot_inpaint.py -imgs "data_images/drosophila_ovary_slice/segm/*.png" --label 0
- python handling_annotations/run_segm_annot_relabel.py -imgs "data_images/drosophila_ovary_slice/center_levels/*.png" -out results/relabel_center_levels

# SEGMENTATION section
- rm -r -f results && mkdir results
- python experiments_segmentation/run_compute-stat_annot-segm.py
- python experiments_segmentation/run_segm_slic_model_graphcut.py --nb_jobs 1
- python experiments_segmentation/run_segm_slic_classif_graphcut.py --nb_jobs 1
- python experiments_segmentation/run_compute_stat_annot_segm.py --visual
- python experiments_segmentation/run_segm_slic_model_graphcut.py --path_config experiments_segmentation/sample_config.json --nb_jobs 1
- python experiments_segmentation/run_segm_slic_classif_graphcut.py --path_config experiments_segmentation/sample_config.json --nb_jobs 1

# CENTER DETECT. section
- rm -r -f results && mkdir results
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include README.md
include LICENSE
include requirements.txt
71 changes: 39 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,35 +118,34 @@ Short description of our three sets of experiments that together compose single

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

* In case you have some smooth color labeling in your images you can remove them with following quantization script.
* **Quantization:** in case you have some smooth color labeling in your images you can remove them with following quantization script.
```bash
python handling_annotations/run_image_color_quantization.py \
-imgs "images/drosophila_ovary_slice/segm_rgb/*.png" \
-imgs "data_images/drosophila_ovary_slice/segm_rgb/*.png" \
-m position -thr 0.01 --nb_jobs 2
```
* Concerting image labels into colour space and other way around.
* **Paint labels:** concerting image labels into colour space and other way around.
```bash
python handling_annotations/run_image_convert_label_color.py \
-imgs "images/drosophila_ovary_slice/segm/*.png" \
-out images/drosophila_ovary_slice/segm_rgb
-imgs "data_images/drosophila_ovary_slice/segm/*.png" \
-out data_images/drosophila_ovary_slice/segm_rgb
```
* Having input image and its segmentation we can use simple visualisation which overlap the segmentation over input image.
* **Visualisation:** having input image and its segmentation we can use simple visualisation which overlap the segmentation over input image.
```bash
python handling_annotations/run_overlap_images_segms.py \
-imgs "images/drosophila_ovary_slice/image/*.jpg" \
-segs images/drosophila_ovary_slice/segm \
-imgs "data_images/drosophila_ovary_slice/image/*.jpg" \
-segs data_images/drosophila_ovary_slice/segm \
-out results/overlap_ovary_segment
```
* Inpainting selected labels in segmentation.
* **Inpainting** selected labels in segmentation.
```bash
python handling_annotations/run_segm_annot_inpaint.py \
-imgs "images/drosophila_ovary_slice/segm/*.png" \
-imgs "data_images/drosophila_ovary_slice/segm/*.png" \
--label 4
```
* Change labels in input segmentation into another set of lables in 1:1 schema.
* **Replace labels:** change labels in input segmentation into another set of lables in 1:1 schema.
```bash
python handling_annotations/run_segm_annot_relabel.py \
-imgs "images/drosophila_ovary_slice/center_levels/*.png" \
-out results/relabel_center_levels \
--label_old 2 3 --label_new 1 1
```
Expand All @@ -159,31 +158,39 @@ We utilize (un)supervised segmentation according to given training examples or s
* Evaluate superpixels (with given SLIC parameters) quality against given segmentation. It helps find out best SLIC configuration.
```bash
python experiments_segmentation/run_eval_superpixels.py \
-imgs "images/drosophila_ovary_slice/image/*.jpg" \
-segm "images/drosophila_ovary_slice/annot_eggs/*.png" \
--img_type 2d_gray \
-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 0
```
* Perform **Unsupervised** segmentation.
* Perform **Unsupervised** segmentation in images given in CSV
```bash
python experiments_segmentation/run_segm_slic_model_graphcut.py \
-list images/langerhans_islets/list_lang-isl_imgs-annot.csv \
-imgs "images/langerhans_islets/image/*.jpg" \
-out results -n langIsl --nb_classes 3 --visual --nb_jobs 2
-l data_images/langerhans_islets/list_lang-isl_imgs-annot.csv -i "" \
--path_config experiments_segmentation/sample_config.json \
-o results -n langIsl --nb_classes 3 --visual --nb_jobs 2
```
OR specified on particuler path:
```bash
python experiments_segmentation/run_segm_slic_model_graphcut.py \
-l "" -i "data_images/langerhans_islets/image/*.jpg" \
--path_config experiments_segmentation/sample_config.json \
-o results -n langIsl --nb_classes 3 --visual --nb_jobs 2
```
* Perform **Supervised** segmentation with afterwards evaluation.
```bash
python experiments_segmentation/run_segm_slic_classif_graphcut.py \
-list images/drosophila_ovary_slice/list_imgs-annot-struct.csv \
-imgs "images/drosophila_ovary_slice/image/*.jpg" \
-out results -n Ovary --img_type 2d_gray --visual --nb_jobs 2
-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.json \
-o results -n Ovary --img_type 2d_split --visual --nb_jobs 2
```
* For both experiment you can evaluate segmentation results.
```bash
python experiments_segmentation/run_compute-stat_annot-segm.py \
-annot "images/drosophila_ovary_slice/annot_struct/*.png" \
-annot "data_images/drosophila_ovary_slice/annot_struct/*.png" \
-segm "results/experiment_segm-supervise_ovary/*.png" \
-img "images/drosophila_ovary_slice/image/*.jpg" \
-img "data_images/drosophila_ovary_slice/image/*.jpg" \
-out results/evaluation
```

Expand All @@ -203,16 +210,16 @@ In general, the input is a formatted list (CSV file) of input images and annotat
1. With zone annotation, we train a classifier for center candidate prediction. The annotation can be a CSV file with annotated centers as points, and the zone of positive examples is set uniformly as the circular neighborhood around these points. Another way (preferable) is to use annotated image with marked zones for positive, negative and neutral examples.
```bash
python experiments_ovary_centres/run_center_candidate_training.py -list none \
-segs "images/drosophila_ovary_slice/segm/*.png" \
-imgs "images/drosophila_ovary_slice/image/*.jpg" \
-centers "images/drosophila_ovary_slice/center_levels/*.png" \
-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
```
1. Having trained classifier we perfom center prediction composed from two steps: i. center candidate clustering and candidate clustering.
```bash
python experiments_ovary_centres/run_center_prediction.py -list none \
-segs "images/drosophila_ovary_slice/segm/*.png" \
-imgs "images/drosophila_ovary_slice/image/*.jpg" \
-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
```
Expand Down Expand Up @@ -269,7 +276,7 @@ python setup.py install
1. Run several segmentation techniques on each image.
```bash
python experiments_ovary_detect/run_ovary_egg-segmentation.py \
-list images/drosophila_ovary_slice/list_imgs-segm-center-points.csv \
-list data_images/drosophila_ovary_slice/list_imgs-segm-center-points.csv \
-out output -n ovary_image --nb_jobs 1 \
-m ellipse_moments \
ellipse_ransac_mmt \
Expand All @@ -289,8 +296,8 @@ python setup.py install
1. In the end, cut individual segmented objects comes as minimal bounding box.
```bash
python experiments_ovary_detect/run_cut_segmented_objects.py \
-annot "images/drosophila_ovary_slice/annot_eggs/*.png" \
-img "images/drosophila_ovary_slice/segm/*.png" \
-annot "data_images/drosophila_ovary_slice/annot_eggs/*.png" \
-img "data_images/drosophila_ovary_slice/segm/*.png" \
-out results/cut_images --padding 50
```
1. Finally, performing visualisation of segmentation results toghter with expert annotation.
Expand Down
20 changes: 10 additions & 10 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ test:
- coverage report && coverage xml -o $CIRCLE_TEST_REPORTS/coverage.xml

# ANNOTATION section
- unset DISPLAY && python handling_annotations/run_image_color_quantization.py -imgs "images/drosophila_ovary_slice/segm_rgb/*.png"
- unset DISPLAY && python handling_annotations/run_image_color_quantization.py -imgs "images/drosophila_ovary_slice/segm_rgb/*.png" -m position
- unset DISPLAY && python handling_annotations/run_image_convert_label_color.py -imgs "images/drosophila_ovary_slice/segm/*.png" -out images/drosophila_ovary_slice/segm_rgb
- unset DISPLAY && python handling_annotations/run_image_convert_label_color.py -imgs "images/drosophila_ovary_slice/segm_rgb/*.png" -out images/drosophila_ovary_slice/segm
- unset DISPLAY && python handling_annotations/run_overlap_images_segms.py -imgs "images/drosophila_ovary_slice/image/*.jpg" -segs images/drosophila_ovary_slice/segm -out results/overlap_ovary_segment
- unset DISPLAY && python handling_annotations/run_segm_annot_inpaint.py -imgs "images/drosophila_ovary_slice/segm/*.png" --label 0
- unset DISPLAY && python handling_annotations/run_segm_annot_relabel.py -imgs "images/drosophila_ovary_slice/center_levels/*.png" -out results/relabel_center_levels
- unset DISPLAY && python handling_annotations/run_image_color_quantization.py -imgs "data_images/drosophila_ovary_slice/segm_rgb/*.png"
- unset DISPLAY && python handling_annotations/run_image_color_quantization.py -imgs "data_images/drosophila_ovary_slice/segm_rgb/*.png" -m position
- unset DISPLAY && 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
- unset DISPLAY && python handling_annotations/run_image_convert_label_color.py -imgs "data_images/drosophila_ovary_slice/segm_rgb/*.png" -out data_images/drosophila_ovary_slice/segm
- unset DISPLAY && 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
- unset DISPLAY && python handling_annotations/run_segm_annot_inpaint.py -imgs "data_images/drosophila_ovary_slice/segm/*.png" --label 0
- unset DISPLAY && python handling_annotations/run_segm_annot_relabel.py -imgs "data_images/drosophila_ovary_slice/center_levels/*.png" -out results/relabel_center_levels

# SEGMENTATION section
- unset DISPLAY && python experiments_segmentation/run_compute-stat_annot-segm.py
- unset DISPLAY && python experiments_segmentation/run_segm_slic_model_graphcut.py --visual
- unset DISPLAY && python experiments_segmentation/run_segm_slic_classif_graphcut.py --visual
- unset DISPLAY && python experiments_segmentation/run_compute_stat_annot_segm.py --visual
- unset DISPLAY && python experiments_segmentation/run_segm_slic_model_graphcut.py --path_config experiments_segmentation/sample_config.json --visual
- unset DISPLAY && python experiments_segmentation/run_segm_slic_classif_graphcut.py --path_config experiments_segmentation/sample_config.json --visual

# CENTER DETECT. section
- unset DISPLAY && python experiments_ovary_centres/run_create_annotation.py
Expand Down
11 changes: 11 additions & 0 deletions data_images/drosophila_disc/list_imaginal-disks.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
,path_image,path_annot
1,data_images/drosophila_disc/image/img_5.jpg,data_images/drosophila_disc/annot/img_5.png
2,data_images/drosophila_disc/image/img_6.jpg,data_images/drosophila_disc/annot/img_6.png
3,data_images/drosophila_disc/image/img_12.jpg,data_images/drosophila_disc/annot/img_12.png
4,data_images/drosophila_disc/image/img_14.jpg,data_images/drosophila_disc/annot/img_14.png
5,data_images/drosophila_disc/image/img_15.jpg,data_images/drosophila_disc/annot/img_15.png
6,data_images/drosophila_disc/image/img_19.jpg,data_images/drosophila_disc/annot/img_19.png
7,data_images/drosophila_disc/image/img_20.jpg,data_images/drosophila_disc/annot/img_20.png
8,data_images/drosophila_disc/image/img_24.jpg,data_images/drosophila_disc/annot/img_24.png
9,data_images/drosophila_disc/image/img_26.jpg,data_images/drosophila_disc/annot/img_26.png
10,data_images/drosophila_disc/image/img_43.jpg,data_images/drosophila_disc/annot/img_43.png
3 changes: 3 additions & 0 deletions data_images/drosophila_disc/list_imaginal-disks_short.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
,path_image,path_annot
1,data_images/drosophila_disc/image/img_6.jpg,data_images/drosophila_disc/annot/img_6.png
2,data_images/drosophila_disc/image/img_43.jpg,data_images/drosophila_disc/annot/img_43.png
11 changes: 11 additions & 0 deletions data_images/drosophila_ovary_slice/list_imgs-annot-struct.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
,path_image,path_annot
1,data_images/drosophila_ovary_slice/image/insitu4174.jpg,data_images/drosophila_ovary_slice/annot_struct/insitu4174.png
2,data_images/drosophila_ovary_slice/image/insitu4358.jpg,data_images/drosophila_ovary_slice/annot_struct/insitu4358.png
3,data_images/drosophila_ovary_slice/image/insitu7331.jpg,data_images/drosophila_ovary_slice/annot_struct/insitu7331.png
4,data_images/drosophila_ovary_slice/image/insitu7544.jpg,data_images/drosophila_ovary_slice/annot_struct/insitu7544.png
5,data_images/drosophila_ovary_slice/image/insitu7545.jpg,data_images/drosophila_ovary_slice/annot_struct/insitu7545.png
6,data_images/drosophila_ovary_slice/image/insitu4174.tif,data_images/drosophila_ovary_slice/annot_struct/insitu4174.png
7,data_images/drosophila_ovary_slice/image/insitu4358.tif,data_images/drosophila_ovary_slice/annot_struct/insitu4358.png
8,data_images/drosophila_ovary_slice/image/insitu7331.tif,data_images/drosophila_ovary_slice/annot_struct/insitu7331.png
9,data_images/drosophila_ovary_slice/image/insitu7544.tif,data_images/drosophila_ovary_slice/annot_struct/insitu7544.png
10,data_images/drosophila_ovary_slice/image/insitu7545.tif,data_images/drosophila_ovary_slice/annot_struct/insitu7545.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
,path_image,path_annot
1,data_images/drosophila_ovary_slice/image/insitu4174.jpg,data_images/drosophila_ovary_slice/annot_struct/insitu4174.png
2,data_images/drosophila_ovary_slice/image/insitu7545.tif,data_images/drosophila_ovary_slice/annot_struct/insitu7545.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
,path_image,path_centers,path_annot,path_segm
1,data_images/drosophila_ovary_slice/image/insitu4174.tif,data_images/drosophila_ovary_slice/center_levels/insitu4174.png,data_images/drosophila_ovary_slice/annot_eggs/insitu4174.png,data_images/drosophila_ovary_slice/segm/insitu4174.png
2,data_images/drosophila_ovary_slice/image/insitu4358.tif,data_images/drosophila_ovary_slice/center_levels/insitu4358.png,data_images/drosophila_ovary_slice/annot_eggs/insitu4358.png,data_images/drosophila_ovary_slice/segm/insitu4358.png
3,data_images/drosophila_ovary_slice/image/insitu7331.tif,data_images/drosophila_ovary_slice/center_levels/insitu7331.png,data_images/drosophila_ovary_slice/annot_eggs/insitu7331.png,data_images/drosophila_ovary_slice/segm/insitu7331.png
4,data_images/drosophila_ovary_slice/image/insitu7544.tif,data_images/drosophila_ovary_slice/center_levels/insitu7544.png,data_images/drosophila_ovary_slice/annot_eggs/insitu7544.png,data_images/drosophila_ovary_slice/segm/insitu7544.png
5,data_images/drosophila_ovary_slice/image/insitu7545.tif,data_images/drosophila_ovary_slice/center_levels/insitu7545.png,data_images/drosophila_ovary_slice/annot_eggs/insitu7545.png,data_images/drosophila_ovary_slice/segm/insitu7545.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
,path_image,path_centers,path_annot,path_segm
1,data_images/drosophila_ovary_slice/image/insitu4358.jpg,data_images/drosophila_ovary_slice/center_levels/insitu4358.png,data_images/drosophila_ovary_slice/annot_eggs/insitu4358.png,data_images/drosophila_ovary_slice/segm/insitu4358.png
2,data_images/drosophila_ovary_slice/image/insitu7545.tif,data_images/drosophila_ovary_slice/center_levels/insitu7545.png,data_images/drosophila_ovary_slice/annot_eggs/insitu7545.png,data_images/drosophila_ovary_slice/segm/insitu7545.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
,path_image,path_centers,path_annot,path_segm
1,data_images/drosophila_ovary_slice/image/insitu4174.jpg,data_images/drosophila_ovary_slice/center_levels/insitu4174.csv,data_images/drosophila_ovary_slice/annot_eggs/insitu4174.png,data_images/drosophila_ovary_slice/segm/insitu4174.png
2,data_images/drosophila_ovary_slice/image/insitu4358.jpg,data_images/drosophila_ovary_slice/center_levels/insitu4358.csv,data_images/drosophila_ovary_slice/annot_eggs/insitu4358.png,data_images/drosophila_ovary_slice/segm/insitu4358.png
3,data_images/drosophila_ovary_slice/image/insitu7331.jpg,data_images/drosophila_ovary_slice/center_levels/insitu7331.csv,data_images/drosophila_ovary_slice/annot_eggs/insitu7331.png,data_images/drosophila_ovary_slice/segm/insitu7331.png
4,data_images/drosophila_ovary_slice/image/insitu7544.jpg,data_images/drosophila_ovary_slice/center_levels/insitu7544.csv,data_images/drosophila_ovary_slice/annot_eggs/insitu7544.png,data_images/drosophila_ovary_slice/segm/insitu7544.png
5,data_images/drosophila_ovary_slice/image/insitu7545.jpg,data_images/drosophila_ovary_slice/center_levels/insitu7545.csv,data_images/drosophila_ovary_slice/annot_eggs/insitu7545.png,data_images/drosophila_ovary_slice/segm/insitu7545.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
,path_image,path_centers,path_annot,path_segm
1,data_images/drosophila_ovary_slice/image/insitu4358.jpg,data_images/drosophila_ovary_slice/center_levels/insitu4358.csv,data_images/drosophila_ovary_slice/annot_eggs/insitu4358.png,data_images/drosophila_ovary_slice/segm/insitu4358.png
2,data_images/drosophila_ovary_slice/image/insitu7545.tif,data_images/drosophila_ovary_slice/center_levels/insitu7545.csv,data_images/drosophila_ovary_slice/annot_eggs/insitu7545.png,data_images/drosophila_ovary_slice/segm/insitu7545.png
Binary file added data_images/langerhans_islets/annot/Lh05-04.png
Binary file added data_images/langerhans_islets/annot/Lh05-09.png
Binary file added data_images/langerhans_islets/annot/Lh09-07.png
Binary file added data_images/langerhans_islets/annot/Lh10-03.png
Binary file added data_images/langerhans_islets/image/Lh05-04.jpg
Binary file added data_images/langerhans_islets/image/Lh05-09.jpg
Binary file added data_images/langerhans_islets/image/Lh09-07.jpg
Binary file added data_images/langerhans_islets/image/Lh10-03.jpg
Loading

0 comments on commit d1da652

Please sign in to comment.