{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "02288901",
"metadata": {
"lines_to_next_cell": 2
},
"outputs": [],
"source": [
"from skimage.io import imread\n",
"import pyclesperanto_prototype as cle # version 0.22.0"
]
},
{
"cell_type": "markdown",
"id": "948f789a",
"metadata": {},
"source": [
"## Loading 'blobs'"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d88bf584",
"metadata": {
"lines_to_next_cell": 2
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 40, 32, 24, ..., 216, 200, 200],\n",
" [ 56, 40, 24, ..., 232, 216, 216],\n",
" [ 64, 48, 24, ..., 240, 232, 232],\n",
" ...,\n",
" [ 72, 80, 80, ..., 48, 48, 48],\n",
" [ 80, 80, 80, ..., 48, 48, 48],\n",
" [ 96, 88, 80, ..., 48, 48, 48]], dtype=uint8)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"image0_b = imread(\"/projects/p_scads_trainings/BIAS/blobs.tif\")\n",
"image0_b"
]
},
{
"cell_type": "markdown",
"id": "853ced0a",
"metadata": {},
"source": [
"## gaussian blur"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ce6be712",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"cle._ image \n",
"\n",
"shape | (254, 256) | \n",
"dtype | float32 | \n",
"size | 254.0 kB | \n",
"min | 10.285456 | max | 248.0 | \n",
" \n",
" \n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"cl.OCLArray([[ 41.428753, 34.696438, 27.733936, ..., 220.92714 , 211.21164 ,\n",
" 206.71573 ],\n",
" [ 47.421425, 38.878723, 30.323011, ..., 228.32323 , 220.60194 ,\n",
" 216.83534 ],\n",
" [ 48.121437, 40.610855, 33.357384, ..., 235.32935 , 229.7049 ,\n",
" 226.88821 ],\n",
" ...,\n",
" [ 74.4386 , 76.32904 , 77.03725 , ..., 48.000324, 48.00075 ,\n",
" 48.001007],\n",
" [ 81.793655, 81.17787 , 79.80763 , ..., 48. , 48. ,\n",
" 48. ],\n",
" [ 88.816925, 85.382095, 81.478806, ..., 48. , 48. ,\n",
" 48. ]], dtype=float32)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"image1_gb = cle.gaussian_blur(image0_b, None, 1.0, 1.0, 0.0)\n",
"image1_gb"
]
},
{
"cell_type": "markdown",
"id": "7b675a36",
"metadata": {},
"source": [
"## threshold otsu"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "8f4bc144",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"cle._ image \n",
"\n",
"shape | (254, 256) | \n",
"dtype | uint8 | \n",
"size | 63.5 kB | \n",
"min | 0.0 | max | 1.0 | \n",
" \n",
" \n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"cl.OCLArray([[0, 0, 0, ..., 1, 1, 1],\n",
" [0, 0, 0, ..., 1, 1, 1],\n",
" [0, 0, 0, ..., 1, 1, 1],\n",
" ...,\n",
" [0, 0, 0, ..., 0, 0, 0],\n",
" [0, 0, 0, ..., 0, 0, 0],\n",
" [0, 0, 0, ..., 0, 0, 0]], dtype=uint8)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"image2_to = cle.threshold_otsu(image1_gb)\n",
"image2_to"
]
},
{
"cell_type": "markdown",
"id": "f5f69e98",
"metadata": {},
"source": [
"## connected components labeling box"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "6af0436b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" | \n",
"\n",
"cle._ image \n",
"\n",
"shape | (254, 256) | \n",
"dtype | uint32 | \n",
"size | 254.0 kB | \n",
"min | 0.0 | max | 62.0 | \n",
" \n",
"\n",
" | \n",
"
\n",
"
"
],
"text/plain": [
"cl.OCLArray([[ 0, 0, 0, ..., 59, 59, 59],\n",
" [ 0, 0, 0, ..., 59, 59, 59],\n",
" [ 0, 0, 0, ..., 59, 59, 59],\n",
" ...,\n",
" [ 0, 0, 0, ..., 0, 0, 0],\n",
" [ 0, 0, 0, ..., 0, 0, 0],\n",
" [ 0, 0, 0, ..., 0, 0, 0]], dtype=uint32)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"image3_cclb = cle.connected_components_labeling_box(image2_to)\n",
"image3_cclb"
]
}
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all",
"main_language": "python",
"notebook_metadata_filter": "-all"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
}
},
"nbformat": 4,
"nbformat_minor": 5
}