{ "cells": [ { "cell_type": "markdown", "id": "41ed60d8-ea49-4d63-ad8e-f36b8ecd7c87", "metadata": {}, "source": [ "# Image variations using Dall-E\n", "In this notebook we will use [Dall-E 2](https://openai.com/dall-e-2) to vary an image. Image variations can be useful for producing multiple example images and studying if algorithms, e.g. for segmentation, are capable to process these images. For convenience reasons, we will use the [Darth-D](https://github.com/haesleinhuepf/darth-d/) library to process the image." ] }, { "cell_type": "code", "execution_count": 1, "id": "75403e01-0341-4fbe-b29a-f51cb7c1e638", "metadata": {}, "outputs": [], "source": [ "from darth_d import vary\n", "\n", "from skimage.io import imread\n", "import stackview" ] }, { "cell_type": "markdown", "id": "ef01f69d-79dc-46f9-a7ec-cd7f7412cff7", "metadata": {}, "source": [ "As examaple image we use this image." ] }, { "cell_type": "code", "execution_count": 2, "id": "afb5dace-ac30-4762-980c-b78c220bcdf9", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
shape(254, 256)
dtypeuint8
size63.5 kB
min8
max248
\n", "\n", "
" ], "text/plain": [ "StackViewNDArray([[ 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": [ "image = imread(\"../../data/blobs.tif\")\n", "stackview.insight(image)" ] }, { "cell_type": "code", "execution_count": 3, "id": "58eafbfb-c82a-4e3c-b8cd-5255229ece03", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\haase\\mambaforge\\envs\\t310\\lib\\site-packages\\darth_d\\_vary.py:36: UserWarning: Using the vary function on scientific images could be seen as scientific misconduct. Handle this function with care.\n", " warn(\"Using the vary function on scientific images could be seen as scientific misconduct. Handle this function with care.\")\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "darth-d made image
\n", "\n", "\n", "\n", "\n", "\n", "
shape(254, 256)
dtypeuint8
size63.5 kB
min16
max254
\n", "\n", "
" ], "text/plain": [ "StackViewNDArray([[174, 148, 130, ..., 253, 252, 252],\n", " [183, 156, 135, ..., 253, 253, 254],\n", " [189, 167, 146, ..., 254, 254, 254],\n", " ...,\n", " [ 65, 62, 61, ..., 195, 197, 198],\n", " [ 54, 58, 60, ..., 183, 185, 184],\n", " [ 56, 61, 62, ..., 162, 163, 163]], dtype=uint8)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output_image = vary(image)\n", "\n", "output_image" ] }, { "cell_type": "markdown", "id": "e722a307-7496-425d-b11c-364cfbe2c17b", "metadata": {}, "source": [ "## Exercise\n", "Load the [`human_mitosis` example from scikit-image](https://scikit-image.org/docs/stable/api/skimage.data.html#skimage.data.human_mitosis) and vary it." ] }, { "cell_type": "code", "execution_count": 4, "id": "6438ce13-92d5-49f6-b419-7e34e0a7be50", "metadata": {}, "outputs": [], "source": [ "from skimage.data import human_mitosis\n", "image = human_mitosis()" ] }, { "cell_type": "code", "execution_count": null, "id": "58389c44-66ac-4b6a-9a4b-a084ceea0649", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "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.10.13" } }, "nbformat": 4, "nbformat_minor": 5 }