Project 9: Shape and texture of damselflies (or parts of them)

In this project, the goal is to extract highly dimensional shape and texture traits from the damselfly Ischnura elegans to investigate the role of correlational selection in a female limited colour polymorphism.

Before

Input - The common bluetail (Ischnura elegans), imaged with a flatbed scanner inside a petri dish.

After

Results - Using multiple contour editing and detection steps the outline ouf the whole animal, as well as specific body parts are segmented.

Images kindly provided by Erik Svensson.

Background

The common bluetail damselfly (Ischnura elegans) expresses remarkably stable female-limited colour polymorphisms across natural populations in Skane (Fig. 1). Females of I. elegans go through a series of abdominal colour changes during development, which results in three female colour morphs: one androchrome morph and two gynochrome morphs (infuscans and infuscans-obsoleta). One hypothesized mechanism thought to stabilize sexual polymorphisms in nature is correlational selection, which occurs when multiple traits (e.g. colouration, morphology or behavior) affect fitness in an interactive way

phenotyping setup

Figure 1: Frequency dependent sexual polymorphisms in Ischnura elegans. Females of I. elegans have three female colour morphs: A (androchrome = male mimicking), I (infuscans) and O (infuscans obsoleta). Selection on multiple traits, i.e., correlational selection, is hypothesized to stabilize morph frequencies over time.

To investigate correlational selection as a stabilizing agent for sexual polymorphisms, a comprehensive analysis of multivariate phenotypes is needed to understand the phenotypic consequences of correlational selection in polymorphic systems. To do so, shape and texture traits are extracted from a large dataset containing images of damselflies belonging to different populations in Skane - this work is conducted by Prof. Erik Svensson and his group.

The segmentation labels that are created with this phenopype configuration will be used to collect training data (from ~ 1500 imgs) to implement a convolutional neural network to perform semantic segmentation on the entire dataset (~ 20000 imgs). However, as an intermediate goal, shape and texture features are extracted to get a first glimpse of how well the collected multivariate, phenomic data fit the expectations.

Preparation

[1]:
import phenopype as pp
import os

## change working dir - will contain project folder
os.chdir(r"D:\git-repos\phenopype\phenopype-gallery\_temp")

## set project name
project_name = "project_9"

## fetch template from downloaded template repo (https://github.com/phenopype/phenopype-templates)
template_path = r"D:\git-repos\phenopype\phenopype-templates\templates\gallery\project_9.yaml"

## set directory with images
image_dir = r"D:\git-repos\phenopype\phenopype-gallery\gallery\data"
phenopype successfully imported the following plugin dependencies:
phenomorph, keras

Extract ROI from images

To have an image size that is more easily manageable, the petridishes are detected and extracted with the detect_mask function shown in https://www.phenopype.org/gallery/project_7/. Then, using save_ROI, the region of interest (ROI) are saved, and used for the project creation

phenotyping setup

Figure 2: Robust circle detection using detect_mask

[2]:
## load image
img_full = pp.load_image(os.path.join(image_dir,"damselflies.jpg"))

## detect_mask needs single channel images
gray = pp.preprocessing.decompose_image(img_full, channel="gray")

## detect circles
circles = pp.preprocessing.detect_mask(
    gray, shape="circle", resize=0.25, circle_args={
        "param1":200,
        "param2":150,
        "min_dist":1000,
        "min_radius":600,
        "max_radius":800}
    )

## create directory to store ROI images
if not os.path.isdir("ROI"):
    os.makedirs("ROI")

## save all ROIs as separate jpeg files
pp.export.save_ROI(
    image=img_full,
    annotations=circles,
    file_name="odonata",
    suffix="roi",
    dir_path="ROI"
    )


- decompose image: using gray channel
- found 1 contours that match criteria
- found 1 contours that match criteria
- found 1 contours that match criteria
- found 1 contours that match criteria
Found 4 circles

Project

[3]:
proj = pp.Project(project_name)
--------------------------------------------
Creating a new phenopype project directory at:
D:\git-repos\phenopype\phenopype-gallery\_temp\project_9

Proceed? (y/n)
y

Project "project_9" successfully created.
--------------------------------------------
[4]:
## import images from the ROI folder
proj.add_files(image_dir = "ROI")
--------------------------------------------
phenopype will search for image files at

D:\git-repos\phenopype\phenopype-gallery\_temp\ROI

using the following settings:

filetypes: ['jpg', 'JPG', 'jpeg', 'JPEG', 'tif', 'png', 'bmp'], include: [], exclude: [], mode: copy, recursive: False, resize: False, unique: path

Found image odonata_roi_00.tif - phenopype-project folder 0__odonata_roi_00 created
Found image odonata_roi_01.tif - phenopype-project folder 0__odonata_roi_01 created
Found image odonata_roi_02.tif - phenopype-project folder 0__odonata_roi_02 created
Found image odonata_roi_03.tif - phenopype-project folder 0__odonata_roi_03 created

Found 4 files - using all
--------------------------------------------
[5]:
## add the config template; provide a tag
proj.add_config(template_path=template_path, tag="v1", overwrite=True)
- template saved under D:\git-repos\phenopype\phenopype-gallery\_temp\project_9\data\0__odonata_roi_00\pype_config_v1.yaml
- template saved under D:\git-repos\phenopype\phenopype-gallery\_temp\project_9\data\0__odonata_roi_01\pype_config_v1.yaml
- template saved under D:\git-repos\phenopype\phenopype-gallery\_temp\project_9\data\0__odonata_roi_02\pype_config_v1.yaml
- template saved under D:\git-repos\phenopype\phenopype-gallery\_temp\project_9\data\0__odonata_roi_03\pype_config_v1.yaml
[6]:
## run image processing
for path in proj.dir_paths:
    pp.Pype(path, tag="v1")

AUTOLOAD
 - nothing to autoload
Stage: fixed method name
Stage: add annotation control args
Stage: add annotation control args
Stage: add annotation control args
Stage: add annotation control args
Stage: add annotation control args
Stage: add annotation control args
Updating pype config: applying staged changes


------------+++ new pype iteration 2022-07-29 11:40:07 +++--------------




PREPROCESSING
write_comment
ID
blur


SEGMENTATION
threshold
- decompose image: using blue channel
morphology
morphology
detect_contour
- found 1 contours that match criteria
edit_contour
detect_contour
- found 1 contours that match criteria
edit_contour
BREAK


------------+++ new pype iteration 2022-07-29 11:40:30 +++--------------




PREPROCESSING
write_comment
- loaded existing annotation of type "comment" with ID "a": skipping (edit=False)
blur


SEGMENTATION
threshold
- decompose image: using green channel
morphology
morphology
detect_contour
- loaded existing annotation of type "contour" with ID "a": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "a": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "b": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "b": skipping (edit=False)
detect_contour
- found 1 contours that match criteria


VISUALIZATION
draw_contour
draw_contour


EXPORT
save_canvas
- image saved under D:\git-repos\phenopype\phenopype-gallery\_temp\project_9\data\0__odonata_roi_00\canvas_v1.jpg.
save_annotation
- creating new annotation file
- no annotation_type selected - exporting all annotations
- writing annotations of type "comment" with id "a" to "annotations_v1.json"
- writing annotations of type "contour" with id "a" to "annotations_v1.json"
- writing annotations of type "contour" with id "b" to "annotations_v1.json"
- writing annotations of type "contour" with id "c" to "annotations_v1.json"
- writing annotations of type "drawing" with id "a" to "annotations_v1.json"
- writing annotations of type "drawing" with id "b" to "annotations_v1.json"


------------+++ finished pype iteration +++--------------
-------(End with Ctrl+Enter or re-run with Enter)--------


AUTOSHOW


------------+++ new pype iteration 2022-07-29 11:40:34 +++--------------




PREPROCESSING
write_comment
- loaded existing annotation of type "comment" with ID "a": skipping (edit=False)
blur


SEGMENTATION
threshold
- decompose image: using green channel
morphology
morphology
detect_contour
- loaded existing annotation of type "contour" with ID "a": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "a": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "b": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "b": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "c": overwriting (edit=overwrite)
- found 1 contours that match criteria


VISUALIZATION
draw_contour
draw_contour


EXPORT
save_canvas
- image saved under D:\git-repos\phenopype\phenopype-gallery\_temp\project_9\data\0__odonata_roi_00\canvas_v1.jpg (overwritten).
save_annotation
- loading existing annotation file
- no annotation_type selected - exporting all annotations
- updating annotations of type "comment" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotations of type "contour" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotations of type "contour" with id "b" in "annotations_v1.json" (overwrite="entry")
- updating annotations of type "contour" with id "c" in "annotations_v1.json" (overwrite="entry")
- updating annotations of type "drawing" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotations of type "drawing" with id "b" in "annotations_v1.json" (overwrite="entry")


------------+++ finished pype iteration +++--------------
-------(End with Ctrl+Enter or re-run with Enter)--------


AUTOSHOW
- STILL UPDATING CONFIG (no content)


------------+++ new pype iteration 2022-07-29 11:40:41 +++--------------




PREPROCESSING
write_comment
- loaded existing annotation of type "comment" with ID "a": skipping (edit=False)
blur


SEGMENTATION
threshold
- decompose image: using red channel
morphology
morphology
detect_contour
- loaded existing annotation of type "contour" with ID "a": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "a": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "b": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "b": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "c": overwriting (edit=overwrite)
- found 1 contours that match criteria


VISUALIZATION
draw_contour
draw_contour


EXPORT
save_canvas
- image saved under D:\git-repos\phenopype\phenopype-gallery\_temp\project_9\data\0__odonata_roi_00\canvas_v1.jpg (overwritten).
save_annotation
- loading existing annotation file
- no annotation_type selected - exporting all annotations
- updating annotations of type "comment" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotations of type "contour" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotations of type "contour" with id "b" in "annotations_v1.json" (overwrite="entry")
- updating annotations of type "contour" with id "c" in "annotations_v1.json" (overwrite="entry")
- updating annotations of type "drawing" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotations of type "drawing" with id "b" in "annotations_v1.json" (overwrite="entry")


------------+++ finished pype iteration +++--------------
-------(End with Ctrl+Enter or re-run with Enter)--------


AUTOSHOW
An exception has occurred, use %tb to see the full traceback.

SystemExit:

TERMINATE (by user)

C:\Miniconda3\envs\pp-dev\lib\site-packages\IPython\core\interactiveshell.py:3560: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
  warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

Modify config to extract shape and texture features

[12]:
target1 = """    - export:"""
replacement1 = """    - measurement:
        - compute_shape_features:
            contour_id: b
        - compute_shape_features:
            contour_id: c
        - compute_texture_features:
            channels: [r, g, b, h, s, v]
            contour_id: b
        - compute_texture_features:
            channels: [r, g, b, h, s, v]
            contour_id: c
    - export:"""

proj.edit_config(tag="v1", target=target1, replacement=replacement1)
# phenopype gallery project 9
# ----------------------------
# segment damselflies and quantify shape and texture of their body parts

config_info:
    config_name: pype_config_v1.yaml
    date_created: '2022-01-20 19:23:30'
    date_last_modified:
    template_name: gallery_project_9.yaml
    template_path: D:\workspace\git-repos\phenopype\phenopype-templates\templates\gallery\gallery_project_9.yaml
processing_steps:
    - preprocessing:
        - write_comment:
            ANNOTATION: {type: comment, id: a, edit: false}
            label: ID
        - blur:
            kernel_size: 5
    - segmentation:
        - threshold:
            method: binary
            value: 90
            channel: blue
        - morphology:
            operation: open
            shape: cross
            kernel_size: 7
            iterations: 2
        - morphology:
            operation: close
            shape: ellipse
            kernel_size: 5
            iterations: 3
        - detect_contour:
            ANNOTATION: {type: contour, id: a, edit: overwrite}
            min_diameter: 0
            min_area: 10000
        - edit_contour:
            ANNOTATION: {type: drawing, id: a, edit: false}
            overlay_blend: 0
            overlay_line_width: 1
        - detect_contour:
            ANNOTATION: {type: contour, id: b, edit: overwrite}
            min_diameter: 0
            min_area: 10000
        - edit_contour:
            ANNOTATION: {type: drawing, id: b, edit: false}
            overlay_blend: 0
            overlay_line_width: 1
        - detect_contour:
            ANNOTATION: {type: contour, id: c, edit: overwrite}
    - visualization:
        - draw_contour:
            contour_id: b
        - draw_contour:
            contour_id: c
            line_colour: aqua
    - measurement:
        - compute_shape_features:
            contour_id: b
        - compute_shape_features:
            contour_id: c
        - compute_texture_features:
            channels: [r, g, b, h, s, v]
            contour_id: b
        - compute_texture_features:
            channels: [r, g, b, h, s, v]
            contour_id: c
    - export:
        - save_canvas:
            resize: 1
        - save_annotation:
            overwrite: true

This is what the new config may look like (can differ beteeen files) - proceed?y
New config saved for 0__odonata_roi_00
New config saved for 0__odonata_roi_01
New config saved for 0__odonata_roi_02
New config saved for 0__odonata_roi_03
[13]:
## run image processing with deactivated feedback
for path in proj.dir_paths:
    pp.Pype(path, tag="v1", feedback=False)
Format path to abspath
- no annotation_type selected - returning all annotations

AUTOLOAD
- annotations loaded:
{
"comment": ["a"],
"contour": ["a", "b", "c"],
"drawing": ["a", "b"]
}
updating pype config file


------------+++ new pype iteration 2022-01-20 19:26:25 +++--------------




PREPROCESSING
write_comment
- loaded existing annotation of type "comment" with ID "a": skipping (edit=False)
blur


SEGMENTATION
threshold
- decompose image: using blue channel
morphology
morphology
detect_contour
- loaded existing annotation of type "contour" with ID "a": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "a": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "b": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "b": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "c": overwriting (edit=overwrite)
- found 4 contours that match criteria


VISUALIZATION
draw_contour
draw_contour


MEASUREMENT
compute_shape_features
compute_shape_features
compute_texture_features
- decompose image: using r channel
Processing r channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00,  8.08it/s]
- decompose image: using g channel
Processing g channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 20.83it/s]
- decompose image: using b channel
Processing b channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 20.82it/s]
- decompose image: using h channel
Processing h channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 20.82it/s]
- decompose image: using s channel
Processing s channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 20.83it/s]
- decompose image: using v channel
Processing v channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 20.83it/s]
compute_texture_features
- decompose image: using r channel
Processing r channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 33.18it/s]
- decompose image: using g channel
Processing g channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 33.33it/s]
- decompose image: using b channel
Processing b channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 33.72it/s]
- decompose image: using h channel
Processing h channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 33.89it/s]
- decompose image: using s channel
Processing s channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 33.59it/s]
- decompose image: using v channel
Processing v channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 33.33it/s]


EXPORT
save_canvas
- image saved under D:\workspace\git-repos\phenopype\phenopype-gallery\_temp\project_9\project\data\0__odonata_roi_00\canvas_v1.jpg (overwritten).
save_annotation
- loading existing annotation file
- updating annotation of type "comment" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "b" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "c" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "drawing" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "drawing" with id "b" in "annotations_v1.json" (overwrite="entry")
- writing annotation of type "shape_features" with id "a" to "annotations_v1.json"
- writing annotation of type "shape_features" with id "b" to "annotations_v1.json"
- writing annotation of type "texture_features" with id "a" to "annotations_v1.json"
- writing annotation of type "texture_features" with id "b" to "annotations_v1.json"
updating pype config file


------------+++ finished pype iteration +++--------------
-------(End with Ctrl+Enter or re-run with Enter)--------




TERMINATE

AUTOSAVE
- nothing to autosave
Format path to abspath
- no annotation_type selected - returning all annotations

AUTOLOAD
- annotations loaded:
{
"comment": ["a"],
"contour": ["a", "b", "c"],
"drawing": ["a", "b"]
}
Fixed method name
updating pype config file


------------+++ new pype iteration 2022-01-20 19:26:27 +++--------------




PREPROCESSING
comment
Fixed method name
- loaded existing annotation of type "comment" with ID "a": skipping (edit=False)
blur


SEGMENTATION
threshold
- decompose image: using blue channel
morphology
morphology
detect_contour
- loaded existing annotation of type "contour" with ID "a": overwriting (edit=overwrite)
- found 3 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "a": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "b": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "b": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "c": overwriting (edit=overwrite)
- found 4 contours that match criteria


VISUALIZATION
draw_contour
draw_contour


MEASUREMENT
compute_shape_features
compute_shape_features
compute_texture_features
- decompose image: using r channel
Processing r channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 27.04it/s]
- decompose image: using g channel
Processing g channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 27.01it/s]
- decompose image: using b channel
Processing b channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 27.76it/s]
- decompose image: using h channel
Processing h channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 28.57it/s]
- decompose image: using s channel
Processing s channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 27.76it/s]
- decompose image: using v channel
Processing v channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 27.01it/s]
compute_texture_features
- decompose image: using r channel
Processing r channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 35.72it/s]
- decompose image: using g channel
Processing g channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 36.17it/s]
- decompose image: using b channel
Processing b channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 35.71it/s]
- decompose image: using h channel
Processing h channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 35.84it/s]
- decompose image: using s channel
Processing s channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 35.72it/s]
- decompose image: using v channel
Processing v channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 35.38it/s]


EXPORT
save_canvas
- image saved under D:\workspace\git-repos\phenopype\phenopype-gallery\_temp\project_9\project\data\0__odonata_roi_01\canvas_v1.jpg (overwritten).
save_annotation
- loading existing annotation file
- updating annotation of type "comment" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "b" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "c" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "drawing" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "drawing" with id "b" in "annotations_v1.json" (overwrite="entry")
- writing annotation of type "shape_features" with id "a" to "annotations_v1.json"
- writing annotation of type "shape_features" with id "b" to "annotations_v1.json"
- writing annotation of type "texture_features" with id "a" to "annotations_v1.json"
- writing annotation of type "texture_features" with id "b" to "annotations_v1.json"
updating pype config file


------------+++ finished pype iteration +++--------------
-------(End with Ctrl+Enter or re-run with Enter)--------




TERMINATE

AUTOSAVE
- nothing to autosave
Format path to abspath
- no annotation_type selected - returning all annotations

AUTOLOAD
- annotations loaded:
{
"comment": ["a"],
"contour": ["a", "b", "c"],
"drawing": ["a", "b"]
}
Fixed method name
updating pype config file


------------+++ new pype iteration 2022-01-20 19:26:28 +++--------------




PREPROCESSING
comment
Fixed method name
- loaded existing annotation of type "comment" with ID "a": skipping (edit=False)
blur


SEGMENTATION
threshold
- decompose image: using blue channel
morphology
morphology
detect_contour
- loaded existing annotation of type "contour" with ID "a": overwriting (edit=overwrite)
- found 2 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "a": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "b": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "b": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "c": overwriting (edit=overwrite)
- found 4 contours that match criteria


VISUALIZATION
draw_contour
draw_contour


MEASUREMENT
compute_shape_features
compute_shape_features
compute_texture_features
- decompose image: using r channel
Processing r channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 24.39it/s]
- decompose image: using g channel
Processing g channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 24.37it/s]
- decompose image: using b channel
Processing b channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 24.39it/s]
- decompose image: using h channel
Processing h channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 24.36it/s]
- decompose image: using s channel
Processing s channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 24.06it/s]
- decompose image: using v channel
Processing v channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 23.81it/s]
compute_texture_features
- decompose image: using r channel
Processing r channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 33.62it/s]
- decompose image: using g channel
Processing g channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 33.90it/s]
- decompose image: using b channel
Processing b channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 33.73it/s]
- decompose image: using h channel
Processing h channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 34.26it/s]
- decompose image: using s channel
Processing s channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 34.48it/s]
- decompose image: using v channel
Processing v channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 34.31it/s]


EXPORT
save_canvas
- image saved under D:\workspace\git-repos\phenopype\phenopype-gallery\_temp\project_9\project\data\0__odonata_roi_02\canvas_v1.jpg (overwritten).
save_annotation
- loading existing annotation file
- updating annotation of type "comment" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "b" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "c" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "drawing" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "drawing" with id "b" in "annotations_v1.json" (overwrite="entry")
- writing annotation of type "shape_features" with id "a" to "annotations_v1.json"
- writing annotation of type "shape_features" with id "b" to "annotations_v1.json"
- writing annotation of type "texture_features" with id "a" to "annotations_v1.json"
- writing annotation of type "texture_features" with id "b" to "annotations_v1.json"
updating pype config file


------------+++ finished pype iteration +++--------------
-------(End with Ctrl+Enter or re-run with Enter)--------




TERMINATE

AUTOSAVE
- nothing to autosave
Format path to abspath
- no annotation_type selected - returning all annotations

AUTOLOAD
- annotations loaded:
{
"comment": ["a"],
"contour": ["a", "b", "c"],
"drawing": ["a", "b"]
}
Fixed method name
updating pype config file


------------+++ new pype iteration 2022-01-20 19:26:30 +++--------------




PREPROCESSING
comment
Fixed method name
- loaded existing annotation of type "comment" with ID "a": skipping (edit=False)
blur


SEGMENTATION
threshold
- decompose image: using blue channel
morphology
morphology
detect_contour
- loaded existing annotation of type "contour" with ID "a": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "a": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "b": overwriting (edit=overwrite)
- found 1 contours that match criteria
edit_contour
- loaded existing annotation of type "drawing" with ID "b": skipping (edit=False)
detect_contour
- loaded existing annotation of type "contour" with ID "c": overwriting (edit=overwrite)
- found 4 contours that match criteria


VISUALIZATION
draw_contour
draw_contour


MEASUREMENT
compute_shape_features
compute_shape_features
compute_texture_features
- decompose image: using r channel
Processing r channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 19.60it/s]
- decompose image: using g channel
Processing g channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 19.60it/s]
- decompose image: using b channel
Processing b channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 20.00it/s]
- decompose image: using h channel
Processing h channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 20.36it/s]
- decompose image: using s channel
Processing s channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 19.60it/s]
- decompose image: using v channel
Processing v channel texture features: 100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 19.21it/s]
compute_texture_features
- decompose image: using r channel
Processing r channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 32.52it/s]
- decompose image: using g channel
Processing g channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 32.77it/s]
- decompose image: using b channel
Processing b channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 32.77it/s]
- decompose image: using h channel
Processing h channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 32.52it/s]
- decompose image: using s channel
Processing s channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 31.34it/s]
- decompose image: using v channel
Processing v channel texture features: 100%|█████████████████████████████████████████████| 4/4 [00:00<00:00, 32.52it/s]


EXPORT
save_canvas
- image saved under D:\workspace\git-repos\phenopype\phenopype-gallery\_temp\project_9\project\data\0__odonata_roi_03\canvas_v1.jpg (overwritten).
save_annotation
- loading existing annotation file
- updating annotation of type "comment" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "b" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "contour" with id "c" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "drawing" with id "a" in "annotations_v1.json" (overwrite="entry")
- updating annotation of type "drawing" with id "b" in "annotations_v1.json" (overwrite="entry")
- writing annotation of type "shape_features" with id "a" to "annotations_v1.json"
- writing annotation of type "shape_features" with id "b" to "annotations_v1.json"
- writing annotation of type "texture_features" with id "a" to "annotations_v1.json"
- writing annotation of type "texture_features" with id "b" to "annotations_v1.json"
updating pype config file


------------+++ finished pype iteration +++--------------
-------(End with Ctrl+Enter or re-run with Enter)--------




TERMINATE

AUTOSAVE
- nothing to autosave
[14]:
## collect results and store in folder "<project-root>/results/annotations"
proj.collect_results("v1", "annotations", "annotations", overwrite=True)
Created D:\workspace\git-repos\phenopype\phenopype-gallery\_temp\project_9\project\results\annotations
Search string: ['annotations_v1']
Collected annotations_v1.json from 0__odonata_roi_00
0__odonata_roi_00_annotations_v1.json saved under D:\workspace\git-repos\phenopype\phenopype-gallery\_temp\project_9\project\results\annotations\0__odonata_roi_00_annotations_v1.json.
Collected annotations_v1.json from 0__odonata_roi_01
0__odonata_roi_01_annotations_v1.json saved under D:\workspace\git-repos\phenopype\phenopype-gallery\_temp\project_9\project\results\annotations\0__odonata_roi_01_annotations_v1.json.
Collected annotations_v1.json from 0__odonata_roi_02
0__odonata_roi_02_annotations_v1.json saved under D:\workspace\git-repos\phenopype\phenopype-gallery\_temp\project_9\project\results\annotations\0__odonata_roi_02_annotations_v1.json.
Collected annotations_v1.json from 0__odonata_roi_03
0__odonata_roi_03_annotations_v1.json saved under D:\workspace\git-repos\phenopype\phenopype-gallery\_temp\project_9\project\results\annotations\0__odonata_roi_03_annotations_v1.json.
[15]:
## display results
import ipyplot ## install with `pip install ipyplot`

canvas_list = []
for path in proj.dir_paths:
    canvas_list.append(pp.load_image(os.path.join(path, "canvas_v1.jpg"), mode="rgb"))

ipyplot.plot_images(canvas_list, img_width=300)
C:\Anaconda3\envs\pp_dev\lib\site-packages\ipyplot\_utils.py:97: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  return np.asarray(seq)

1