{ "cells": [ { "cell_type": "markdown", "id": "9926f359fcd20f35", "metadata": {}, "source": [ "# 1. Getting Started\n", "\n", "Get started with image processing in PhenoTypic.\n", "\n", "---\n", "\n", "Getting started with image processing is straightforward. There's three classes of operations in `phenotypic`: `ImageOperation`, `MeasureFeature`, and `ImagePipeline`.\n", "\n", "- `ImageOperation`(s): processes that operate on the data of an image in preparation for feature extraction with `MeasureFeature`.\n", "- `MeasureFeature`(s) extract measurements from the objects within the image based on the pixel values.\n", "- `ImagePipeline`(s) are a collection of operations and measurements compiled into a single class for convenience.\n", "\n", "To get started with `phenotypic`, it's fastest to start by using one of the pipelines in `phenotypic.prefab`. Below we use `phenotypic.prefab.HeavyWatershedPipeline`, which was used for images of *Kluveromyces Marxianus* taken using an Epson V850 Pro Scanner.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "initial_id", "metadata": { "ExecuteTime": { "end_time": "2025-11-25T23:02:55.727552Z", "start_time": "2025-11-25T23:02:54.419591Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "../../../../../src/phenotypic/data/PhenoTypicSampleSubset/6_1S_7.jpg\n" ] } ], "source": [ "import phenotypic as pht\n", "\n", "filepaths = [x for x in pht.data.yield_sample_dataset(mode=\"filepath\")]\n", "print(filepaths[-2]) # lets show the filepath we'll be using" ] }, { "cell_type": "code", "execution_count": 2, "id": "f5165586a9c8ebe4", "metadata": { "ExecuteTime": { "end_time": "2025-11-25T23:02:55.795096Z", "start_time": "2025-11-25T23:02:55.731356Z" } }, "outputs": [], "source": [ "# We're gonna import the last image in the dataset, lets make an image with a grid in 96 array format\n", "# Accepted filepaths are jpegs, tiffs, pngs, and RAW format files\n", "# These images are jpegs so we set a bit depth of 8.\n", "image = pht.GridImage.imread(filepaths[-2], nrows=8, ncols=12, bit_depth=8)\n", "image.show()" ] }, { "cell_type": "markdown", "id": "392baba8c1a222f8", "metadata": {}, "source": [ "## Processing your first image\n", "\n", "---\n", "Here we're gonna import the last image in the dataset, since its from the last timepoint and should have reasonable growth. Accepted file formats are jpegs, tiffs, pngs, and RAW files.\n", "\n", "**Important things to note:**\n", " - `bit_depth` will have an important role in memory usage and accuracy. For jpegs, this will always be 8. For other image formats, consult your camera documentation for information. You may also find this information in your image metadata, depending on the format. PhenoTypic supports bit depths of 8 and 16. If not provided, PhenoTypic will try to guess this information from the imported image data." ] }, { "cell_type": "code", "execution_count": 3, "id": "79bf12b65fffaca3", "metadata": { "ExecuteTime": { "end_time": "2025-11-25T23:03:21.395084Z", "start_time": "2025-11-25T23:02:55.798875Z" } }, "outputs": [ { "data": { "text/html": [ "
| \n", " | Metadata_FileSuffix | \n", "Metadata_BitDepth | \n", "Metadata_ImageType | \n", "Metadata_ImageName | \n", "ObjectLabel | \n", "Bbox_CenterRR | \n", "Bbox_CenterCC | \n", "Bbox_MinRR | \n", "Bbox_MinCC | \n", "Bbox_MaxRR | \n", "... | \n", "ColorHSV_BrightnessMin | \n", "ColorHSV_BrightnessQ1 | \n", "ColorHSV_BrightnessMean | \n", "ColorHSV_BrightnessMedian | \n", "ColorHSV_BrightnessQ3 | \n", "ColorHSV_BrightnessMax | \n", "ColorHSV_BrightnessStdDev | \n", "ColorHSV_BrightnessCoeffVar | \n", "ColorLab_ChromaEstimatedMean | \n", "ColorLab_ChromaEstimatedMedian | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", ".jpg | \n", "8 | \n", "GridImage | \n", "6_1S_7 | \n", "1 | \n", "139.576551 | \n", "686.713517 | \n", "110 | \n", "657 | \n", "172 | \n", "... | \n", "0.309804 | \n", "0.435294 | \n", "0.448946 | \n", "0.462745 | \n", "0.478431 | \n", "0.498039 | \n", "0.043166 | \n", "0.096185 | \n", "5.538571 | \n", "5.791290 | \n", "
| 1 | \n", ".jpg | \n", "8 | \n", "GridImage | \n", "6_1S_7 | \n", "2 | \n", "148.151559 | \n", "362.125000 | \n", "113 | \n", "331 | \n", "184 | \n", "... | \n", "0.313725 | \n", "0.454902 | \n", "0.477968 | \n", "0.498039 | \n", "0.517647 | \n", "0.545098 | \n", "0.052580 | \n", "0.110040 | \n", "6.499312 | \n", "6.811936 | \n", "
| 2 | \n", ".jpg | \n", "8 | \n", "GridImage | \n", "6_1S_7 | \n", "3 | \n", "147.168975 | \n", "535.913820 | \n", "115 | \n", "505 | \n", "180 | \n", "... | \n", "0.317647 | \n", "0.443137 | \n", "0.479812 | \n", "0.505882 | \n", "0.521569 | \n", "0.552941 | \n", "0.058114 | \n", "0.121155 | \n", "7.063123 | \n", "7.547446 | \n", "
| 3 | \n", ".jpg | \n", "8 | \n", "GridImage | \n", "6_1S_7 | \n", "4 | \n", "150.986417 | \n", "1011.233214 | \n", "116 | \n", "977 | \n", "187 | \n", "... | \n", "0.313725 | \n", "0.462745 | \n", "0.481581 | \n", "0.501961 | \n", "0.517647 | \n", "0.537255 | \n", "0.051533 | \n", "0.107035 | \n", "5.642369 | \n", "5.792222 | \n", "
| 4 | \n", ".jpg | \n", "8 | \n", "GridImage | \n", "6_1S_7 | \n", "5 | \n", "145.111368 | \n", "1969.141950 | \n", "120 | \n", "1947 | \n", "171 | \n", "... | \n", "0.321569 | \n", "0.419608 | \n", "0.439005 | \n", "0.447059 | \n", "0.466667 | \n", "0.517647 | \n", "0.041147 | \n", "0.093781 | \n", "8.118938 | \n", "8.275674 | \n", "
5 rows × 172 columns
\n", "