920 lines
1.1 MiB
Plaintext
920 lines
1.1 MiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-1d6811de1e292425",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"In this notebook, we explore how to detect a moving object on a stationary background."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-c101bf39d596ef9a",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"from scipy import ndimage\n",
|
||
|
"\n",
|
||
|
"# If import imageio fails, you can install it like this in Jupyter:\n",
|
||
|
"# !pip install 'imageio[ffmpeg]'\n",
|
||
|
"# or like this at the command line:\n",
|
||
|
"# python -m pip install 'imageio[ffmpeg]'\n",
|
||
|
"import imageio"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-7161f550b1a10a31",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Here we define a helper function which we call below to make sure\n",
|
||
|
"# an image is an \"unsigned 8 bit integer\". This way, we know they\n",
|
||
|
"# take only a single byte per pixel and have a value from 0..255.\n",
|
||
|
"\n",
|
||
|
"def ensure_dtype_uint8(arr):\n",
|
||
|
" return arr.astype(np.uint8)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-108186f7f14d851d",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Here we load the first frame of a movie file saved in the Straw Lab of a fly walking."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-721f647abba6218f",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"fname = \"data/short-movie20170810_182130.mp4\"\n",
|
||
|
"reader = imageio.get_reader(fname)\n",
|
||
|
"for frame in reader:\n",
|
||
|
" frame0 = frame[:,:,1] # take only green channel\n",
|
||
|
" break"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-6589753ba9570c6b",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Now, we plot the first frame (the first image) in the video. We do this once in grayscale and once in false color."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-f8d6f9c412400ac4",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
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2dnQfGiyL1fPGgpBhXcJwY6LBicz/UBfiw4iPfH4uKicrmczs7OEm1gcYwX+PhvFiXpXNkWi8XEwpTWt7SHHxYgQAjHc6735Ww209nZWeI99Pv9oMBns1lQ+iyWPr78XO8LBODCu+H34uKixuNx4jkWFhZUKpUS7fQff26uSb8ytmNQ7Nehf1hofUzSdsYdc4L3waLL+TEw4lz6zEFuDKr5nrFyenqqs7OzAKRZuIfDYaJ9ADkHvrSFMeL3OD09DUCC8UQ7eYf0Q6VSSfQD79vHDtfhfzdUfPxOp1ONx2MVCgUVi0V90Rd9kf70T/9Uu7u7n9UilcvlVCqVVC6Xw9xEzs7OArgdj8dhnD0MuQoYP0qSuePfXnlkQUexWNQ73/lOffjDH9a3fuu3hs8//OEP62/9rb/1hq9TKpUSC7SkS4qVz1ggARkoBJQ2C4cvRlicSPw313VLyQXF50yCK0T/cRCDsuQaKHe30lwRotBpC0oPBcr3CIoYABBbZrTHrTj/nOf3Nvoz+WIS9w1t5N7x4sO78AWLRQtxsISS5XsWC7eM43fiYCTuX47xvnZhHJ2enmo0Gmk4HF4CZb5AO3ADIHs/uwCGHABzPRZU+j5+Lo51qz/tGm5xpzEofn8WVN45c8QBjIMdGC5feDnfwXv8Lv13zMg5s+LgJwZg/p5iEMv14rno/U77YMNms1kCsPBu6EuATsye+rv1+zlDQ98uLi7qC7/wC1UqlXTv3r1LQDVNFhYWgrHlcwtAc3p6GtiYNGb1YYjrgCdR3izL8zj33SMLOiTpgx/8oP7e3/t7+vIv/3L9pb/0l/TTP/3TevXVV/WP//E/fsPXSKOL489RIm6FOav
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.imshow(frame0, cmap='gray')\n",
|
||
|
"plt.colorbar();"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-79ff5ac403dbec51",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh0AAAGOCAYAAAAzerGXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9e5RcZ3XnjX9a53SdunaXutrdrZbablmSZWQJy0hEji/YgLEJOGAugSTDzHgmzEteLhO/hHfWZHjXb8isTJxkkgkzIdchgzMhBGYYMIQ4gB2wsdFYIIOMjGxZktV2yy11q6tVraquqlN1Tvfvj/3s5zxVksHGF2yr9lq9uvvUqVOnzu35Pt/93d/dt7KyskIvetGLXvSiF73oxfMcq37aO9CLXvSiF73oRS/OjeiBjl70ohe96EUvevGCRA909KIXvehFL3rRixckeqCjF73oRS960YtevCDRAx296EUvetGLXvTiBYke6OhFL3rRi170ohcvSPRARy960Yte9KIXvXhBogc6etGLXvSiF73oxQsS/k97B3rRi170ohe9OFei2WzSarWe9XZSqRTpdPo52KMXNnqgoxe96EUvetGLFyCazSbnZTLUnoNtjY2NcfTo0Zcc8OiBjl70ohe96EUvXoBotVrUgP8XCJ7FdkLgP504QavV6oGOXvSiF73oRS968dQRAC8tqPDcRU9I2ote9KIXvejFCxj9z8HPM4lbb72VV7/61RQKBUZGRrjppps4ePBgxzo333wzfX19HT+XX355xzphGPKhD32I4eFhcrkcb3nLWzh27Ngz2pce6OhFL3rRi1704gUM/zn4eSZxzz338IEPfID777+fO++8kyiKuP7661laWupY741vfCPHjx+3P3fccUfH67fccgtf/OIX+exnP8t9991HrVbjxhtvJI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rnuAZiDXfJPkfg+AwTZ96ZZ8bz/G8yLCpazcO7PmHs2Ze7MMLJHc36HZhv6t96173zfN303n/fuB/z0F/C9wzsfTDx84DxgBViMPBf07Y7Y5BxwEHgWqP+HnPNN9ypi/2yQPzxdDhMAfdrRyf76iZ4P+Iozh4WE8zzuD1ZibmzuD/QAIgoAgCM5YzsQA5AaSb6oAI6ITLKSRM6nAwH0o+M76ujyFgI8cCZBx71fP2a77czZFUNq8R7fvgokUidw3TwI63IRg1PU7DRRX6C9WgX7iyGPZPFTbfo7+gSb9QBRn6V+Vpt1fEPBQjIkjn3YzxSo/ZrmZkgd31AfpNmTM3+ixElDT9tP0pUKCgRaBH5PyQnw8QgKy1Mmywgh1PJYJyQOe2f2MHTQDQrL4+GTxyRmgADE+Ker04ZEyB9pjFW3SzimVA9SHx7IZWFfoY5AyRaq0SDFPiQbDQDIYnyLgNOtoEVA3jaYrBphUKdhlMR4hKbojxu8YnFsETM9OsPxITpKuEZwehvaVT1CnagfYiBY1YIk6FarOJRN3AJx589kay8SkqJAjom2G+LZ5rUCVEWaJzRAdkqJFYIBOQD+wCo/AbNPDpx9YJiBtjllAnwUcvvnckIAcPgF9xKTpI0XKAEfZZzMQE+HTj88yaVqspk6MT4M8IQGR+YwWAQVWEbEKCIjJ4RFSJKZuYJOHZ6BmgGc/JyZFTIoVPFYo0sbDp0KRJueRsfvRogXMpNIsRx796T4gzdK8yXv7KxD3sRLCUghLrbZcy32+AOtCLKB7vr/zfi60WfFj+tMtsvk6nt/HciVNe2kA1pLcwz6dE5Gm+dH7VZ8jilXTznv1tRayTz8LnPdK+LNR4JNgz/bTiX7gAmATUCAZ6EHAxZMI4DhmfreRh5bH8xv6kMV81otPUthLxz+
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.imshow(frame0, cmap='jet')\n",
|
||
|
"plt.colorbar();"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-b4d51617498cdf00",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Note how the false color image lets you see more easily approximately what pixel intensity values are present."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-bb6b6c1075212bfa",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Now, list make a histogram of the pixel intensity values."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-1f03feb12c388aa0",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
},
|
||
|
"scrolled": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkIAAAGdCAYAAAD+JxxnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAutElEQVR4nO3dbVBUZ4L+/4ugdAgLZ3AINK1Eqd2Jq8FYNZhVNBMcH1BLNI5bpRMmlNSm2GR8KgqsbNy8iLE24maVzJZOnBk3FRM1IS+UVLZ0GFCjDqUoIVKB6BiroiNGWoyD3cpog3j/X8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LY+Pj5eUVFRd8zceH4jc7Pi4mL3vCTHcZSSknLPYwIAAPqWLh0a+78WL16sL774QlVVVWHL58+f7/47LS1NY8aM0dChQ7Vjxw7NnTv3tu9njAk7VHWrw1bdkblxovTtDostX75chYWF7vNgMEgZAgCgn7qvGaElS5bok08+0aeffqohQ4bcMZucnKyhQ4fqxIkTkiSv16u2tja1tLSE5Zqbm93ZGq/Xq3PnznV6r/Pnz4dlbp7VaWlpUXt7+x0zNw7T3TxTdIPH41FcXFzYAwAA9E9dKkLGGC1evFjbt2/Xnj17lJqaetfXXLhwQY2NjUpOTpYkpaena+DAgaqsrHQzTU1Namho0Pjx4yVJGRkZCgQCOnz4sJs5dOiQAoFAWKahoUFNTU1upqKiQh6PR+np6W5m//79YZfUV1RUyOfzadiwYV3ZdQAA0A91qQg
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.hist(frame0.flat, bins=30);"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-b8ef9c796dcc7da1",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Now we will load all the frames into a single large data structure from disk into memory."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-d8d4b833e722c306",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"(102, 1024, 1280)\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# get all frames into big 3D array\n",
|
||
|
"(height,width) = frame0.shape\n",
|
||
|
"all_frames = []\n",
|
||
|
"reader.set_image_index(0) # return to start of file\n",
|
||
|
"for frame in reader:\n",
|
||
|
" all_frames.append( frame[:,:,1] )\n",
|
||
|
"all_frames = np.array(all_frames)\n",
|
||
|
"print(all_frames.shape)\n",
|
||
|
"n_frames = len(all_frames)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-3ef9393de49f1ec7",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Now the entire movie is stored as a large 3D array of size: number of frames x width x height."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-c2722d719e790f09",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Now, we want to find a fly in the image. The fly is moving, but the background is stationary, so we should be able to determine a single \"background image\". We can try to find the background image in at least two ways: with a \"mean image\" (also \"average image\"), which should average over the fly's position. And with a \"median image\" which should completely eliminate the fly from the backround image if the fly was absent for most of the time from each pixel."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-2f4ea267c6c2ccd9",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"mean_frame = np.mean(all_frames, axis=0)\n",
|
||
|
"median_frame = np.median(all_frames, axis=0)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-e2365cb18d5b20d1",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh0AAAGOCAYAAAAzerGXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9e5RcZ3XnjX9a53SdunaXutrdrZbaalmSZWQJy0hEji/YgMEOOGAuA0mGmWEmzI+8XCb8CO+syfCu35BZmZBkkkneCbkOGcjEITBhuIU4XBywsVEsItkyMrJlSVbbLbfUra5Wtaq6qk7VOd2/P/azn/NUSQYbX7Ct2mvVqqpzvz7P9/nu7967b2VlZYWe9axnPetZz3rWs+fYVv2kD6BnPetZz3rWs55dGNYDHT3rWc961rOe9ex5sR7o6FnPetaznvWsZ8+L9UBHz3rWs571rGc9e16sBzp61rOe9axnPevZ82I90NGznvWsZz3rWc+eF+uBjp71rGc961nPeva8WA909KxnPetZz3rWs+fF/J/0AfSsZz3rWc96dqFYs9mk1Wo94+2kUinS6fSzcETPr/VAR8961rOe9axnz4M1m00uymSoPQvbGhsb4/jx4y864NEDHT3rWc961rOePQ/WarWoAf83EDyD7YTAfz11ilar1QMdPetZz3rWs5717MktAF5cUOHZs56QtGc961nPetaz59H6n4XP07GPf/zjvPKVr6RQKDAyMsKtt97K4cOHO5Z597vfTV9fX8fnqquu6lgmDEM++MEPMjw8TC6X401vehMnTpx4WsfSAx0961nPetaznj2P5j8Ln6djd911F+9///u59957+eY3v0kURbz+9a9naWmpY7mbb76ZkydP2s/tt9/eMf9DH/oQX/ziF/nsZz/LPffcQ61W45ZbbiGO46d17j3rWc961rOe9ewlal/72tc6/n/qU59iZGSE/fv386pXvcpOD4KAsbGx825jcXGRP//zP+cv//IvufHGGwG47bbbmJiY4I477uCmm256SsfSYzp61rOe9axnPXsezeeZuVaULTh79mzHJwzDp7T/xcVFAIaGhjqm33nnnYyMjHDppZfyb//tv2Vubs7O279/P+12m9e//vV22vj4ONu2bWPPnj1P+dx7oKNnPetZz3rWs+fRni33ysTEBIODg/bz8Y9//Efue2VlhQ9/+MNce+21bNu2zU7/mZ/5Gf7qr/6Kb33rW/zu7/4u//RP/8RrXvMaC2ROnTpFKpVi9erVHdsbHR3l1KlTT+vce9aznvWsZz3r2YvMpqenGRgYsP+D4EcH4n7gAx/g+9//Pvfcc0/H9He+853297Zt29i1axfr16/n7/7u73jrW9/6pNtbWVmhr6/vKR9zD3T0rGc961nPevY82o8TgeJaZL4HBgY6QMePsg9+8IN85Stf4Tvf+Q7r1q37ocuuWbOG9evXc+TIEUCSkbVaLc6cOdPBdszNzXH11Vc/5WPouVd61rOe9axnPXse7fmOXllZWeEDH/gAX/jCF/jWt77Fhg0bfuQ65XKZ6elp1qxZA8DOnTvp7+/nm9/8pl3m5MmTPPjgg08LdPSYjp71rGc961nPnkdTIemPa+2nufz73/9+PvOZz/DlL3+ZQqFgNRiDg4NkMhlqtRof+9jHeNvb3saaNWuYmpriP/7H/8jw8DBvectb7LK/+Iu/yK/8yq9QKpUYGhriIx/5CNu3b7fRLE/FeqCjZz3rWc961rOXsP3xH/8xADfccEPH9E996lO8+93vxvM8Dh48yP/6X/+LSqXCmjVrePWrX83nPvc5CoWCXf73fu/38H2fd7zjHTQaDV772tfy6U9/Gs/znvKx9K2srKw8K2fVs571rGc961nPntTO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
"text/plain": [
|
||
|
"<Figure size 640x480 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.imshow(mean_frame, cmap='jet')\n",
|
||
|
"plt.colorbar();"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-58ec1fa04a85c5db",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh0AAAGOCAYAAAAzerGXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9e5RcZ3XnD39a53SdunaXutrdrZbaalmSZWQJy0hEji/YgMFOcIy5DCQZZoaZZF7y4zLhJfxmTYZZ75BZmZBkMhNmQi6TIQNJHAITwj2EiwM2NhqLSCAjI1uWZLXdckvd6mpVq6qr6lSd0/3+sZ/9nKdKMtj4gi3VXqtWVZ379Xm+z97f/d19KysrK/SsZz3rWc961rOePce26id9AD3rWc961rOe9ezisB7o6FnPetaznvWsZ8+L9UBHz3rWs571rGc9e16sBzp61rOe9axnPevZ82I90NGznvWsZz3rWc+eF+uBjp71rGc961nPeva8WA909KxnPetZz3rWs+fFeqCjZz3rWc961rOePS/m/6QPoGc961nPetazi8WazSatVusZbyeVSpFOp5+FI3p+rQc6etaznvWsZz17HqzZbHJJJkPtWdjW2NgYx48ff9EBjx7o6FnPetaznvXsebBWq0UN+H+B4BlsJwT+y6lTtFqtHujoWc961rOe9axnT24B8OKCCs+e9YikPetZz3rWs549j9b/LHyejn3oQx/i5S9/OYVCgZGREe644w4OHz7csczb3/52+vr6Oj7XXHNNxzJhGPKe97yH4eFhcrkct99+OydOnHhax9IDHT3rWc961rOePY/mPwufp2P33HMP73rXu7j//vv5+te/ThRFvPa1r2VpaaljuVtvvZWTJ0/az5e//OWO+e9973v57Gc/yyc/+Unuu+8+arUat912G3EcP61z71nPetaznvWsZxeofeUrX+n4/7GPfYyRkRH279/PK17xCjs9CALGxsbOu43FxUX+7M/+jL/8y7/k5ptvBuDOO+9kYmKCu+66i1tuueUpHUvP09GznvWsZz3r2fNoPs8stKLegrNnz3Z8wjB8SvtfXFwEYGhoqGP63XffzcjICJdffjn/+l//a+bm5uy8/fv30263ee1rX2unjY+Ps23bNvbs2fOUz70HOnrWs571rGc9ex7t2QqvTExMMDg4aD8f+tCHfuS+V1ZWeN/73sf111/Ptm3b7PSf+Zmf4a/+6q/4xje+wX/9r/+Vf/zHf+RVr3qVBTKnTp0ilUqxevXqju2Njo5y6tSpp3XuPetZz3rWs5717EVm09PTDAwM2P9B8KMTcd/97nfz/e9/n/vuu69j+lvf+lb7e9u2bezatYv169fzd3/3d7zxjW980u2trKzQ19f3lI+5Bzp61rOe9axnPXse7cfJQHEtMt8DAwMdoONH2Xve8x6+8IUv8K1vfYt169b90GXXrFnD+vXrOXLkCCBiZK1WizNnznR4O+bm5rj22muf8jH0wis961nPetaznj2P9nxnr6ysrPDud7+bz3zmM3zjG99gw4YNP3KdcrnM9PQ0a9asAWDnzp309/fz9a9/3S5z8uRJHnzwwacFOnqejp71rGc961nPnkdTIumPa+2nufy73vUuPvGJT/D5z3+eQqFgORiDg4NkMhlqtRof/OAHedOb3sSaNWuYmpri3//7f8/w8DBveMMb7LK/9Eu/xK/92q9RKpUYGhri/e9/P9u3b7fZLE/FeqCjZz3rWc961rML2P74j/8YgJtuuqlj+sc+9jHe/va343keBw8e5C/+4i+oVCqsWbOGV77ylXzqU5+iUCjY5X//938f3/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A0tGDgIsnEMBxwny3kUbL47m1fpIT9oAXHqWwF45/bu0
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.imshow(median_frame, cmap='jet')\n",
|
||
|
"plt.colorbar();"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-5faa20bd7e208895",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Now that we have the \"background\", we can find the difference from background, which should emphasize anything that is moving."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-074247293d712cac",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh0AAAGOCAYAAAAzerGXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABbdUlEQVR4nO3dfXgU9b03/nfIbpaQJisJJcvWoPG+06oNKgZLRY7g4UnLg8rVgoKId/n14EHQCMrDoVb00kRoBc4xRyxeVqiU4tW7Ym1rlWAVyg0KBqOAFuppCkGJsRp3E4zJJpnfH8t3MzvZ3ezuPOw8vF/XNRdkd3b2O7Mz3/nM9zFLkiQJRERERDobkOkEEBERkTMw6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bro3YSsN8iavYpCnW9yA3UjtRmxmYv9i/a4hhBubfo7Ufrsgki/lMCKg6+/cc8OZASaZ0dmzZ3H55ZejpqYm4Xovvvgi3nrrLfj9/j7vVVZWYufOndixYwf27duHtrY2TJs2Dd3d3Umnw6EFPGQ+Vgkc9OKGdbqZJlN1IqRSqqZF1YSZxggxQxrIlDJQvXLDDTfghhtuSLjORx99hMWLF+PVV1/F1KlTo94LBAJ45pln8Nxzz2HixIkAgG3btqGkpAS7d+/GlClTkkoHSzoow5z+NCiCDZED6dFeQUu5AArRWzIj/80S/YapBChqdAEoSJAOJ+ExMC0xy2y6y7k7dzAYjFo6OjrSTlJPTw/mzZuH+++/H9/+9rf7vF9XV4dQKITJkydHXvP7/SgvL8f+/fuT/h4GHZR
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"frame0_absdiff = abs(frame0 - median_frame)\n",
|
||
|
"plt.imshow(frame0_absdiff, cmap='jet')\n",
|
||
|
"plt.colorbar();"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-798add9cb796580b",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Now lets make a histogram of the `frame0_absdiff` image."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-c71b6c10e0ee3018",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAioAAAGsCAYAAADzMYzrAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAj90lEQVR4nO3df1TUVeL/8dcIMpjJtGjyIxHJzfKEuTqWQVHqJkVmeWqTtja0tBO7linZSfLTDz2esDY91ppmJ808a8a2mVsrp6STP7POJmI/zFOWJKQQB9sG1BoQ7vcPv047gcqMCJeZ5+OcOae5vN8zd957kee+55fDGGMEAABgoS4dPQEAAIATIVQAAIC1CBUAAGAtQgUAAFiLUAEAANYiVAAAgLUIFQAAYC1CBQAAWItQAQAA1iJUAACAtTpVqGzevFljx45VYmKiHA6H1q5dG/BtGGP0zDPPaMCAAXI6nUpKStKTTz7Z9pMFAACnLbKjJxCIw4cPa/Dgwbrrrrt0yy23BHUbDzzwgNavX69nnnlGgwYNksfjUU1NTRvPFAAAtAVHZ/1SQofDoTfffFPjxo3zjdXX1+v//u//tGrVKv34449KTU3VU089pREjRkiSdu/erUsuuUSff/65Lrzwwo6ZOAAAaLVO9dTPqdx111364IMP9Nprr+nTTz/Vrbfequuuu0579uyRJL399ts6//zz9e9//1spKSnq16+fJk+erB9++KGDZw4AAFoSMqHyzTffaPXq1Xr99deVkZGh/v37a8aMGbryyiv18ssvS5L27t2rffv26fXXX9fKlSu1YsUKlZSU6A9/+EMHzx4AALSkU71G5WR27NghY4wGDBjgN+71etWzZ09JUlNTk7xer1auXOnbbtmyZXK73fryyy95OggAAMuETKg0NTUpIiJCJSUlioiI8PvZ2WefLUlKSEhQZGSkX8wMHDhQklReXk6oAABgmZAJlSFDhqixsVHV1dXKyMhocZsrrrhCR48e1TfffKP+/ftLkr766itJUnJycrvNFQAAtE6netfPoUOH9PXXX0s6FiYLFizQyJEjFRsbq759++pPf/qTPvjgA82fP19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Tqkr7/+2ne9rKxMO3fuVGxsrPr27av8/Hzt379fK1eulHQsUnJycvTss8/q8ssvV1VVlSSpW7ducrlcbfQwAABAKAr4jMr27ds1ZMgQ31uL8/LyNGTIED322GOSpMrKSpWXl/u2X7p0qY4ePaopU6YoISHBd3nggQfa6CEAAIBQFfAZlREjRsgYc8Kfr1ixwu/6xo0bA70LAAAASXzXDwAAsBihAgAArEWoAAAAaxEqAADAWoQKAACwFqECAACsRagAAABrESoAAMBahAoAALAWoQIAAKxFqAAAAGsRKgAAwFqECgAAsBahAgAArEWoAAAAaxEqAADAWoQKAACwFqECAACsRagAAABrESoAAMBahAoAALAWoQIAAKxFqAAAAGsRKgAAwFqECgAAsBahAgAArEWoAAAAaxEqAADAWoQKAACwFqECAACsRagAAABrESoAAMBahAoAALAWoQIAAKxFqAAAAGsRKgAAwFqECgAAsBahAgAArEWoAAAAaxEqAADAWoQKAACwFqECAACsFXCobN68WWPHjlViYqIcDofWrl17yn02bdokt9ut6OhonX/++XrhhReCmSsAAAgzAYfK4cOHNXjwYC1atKhV25eVlen6669XRkaGSktL9cgjj2jq1Kl64403Ap4sAAAIL5GB7pCVlaWsrKxWb//CCy+ob9++WrhwoSRp4MCB2r59u5555hndcsstgd49AAAII2f8NSoffvihMjMz/cauvfZabd++XQ0NDS3u4/V6VVtb63cBAADh54yHSlVVleLi4vzG4uLidPToUdXU1LS4T0FBgVwul++SlJR0pqcJAAAs1C7v+nE4HH7XjTEtjh+Xn58vj8fju1RUVJzxOQIAAPsE/BqVQMXHx6uqqspvrLq6WpGRkerZs2eL+zidTjmdzjM9NQAAYLkzfkYlLS1NxcXFfmPr16/XsGHD1LVr1zN99wAAoBMLOFQOHTqknTt3aufOnZKOvf14586dKi8vl3TsaZucnBzf9rm5udq3b5/y8vK0e/duLV++XMuWLdOMGTPa5hEAAICQFfBTP9u3b9fIkSN91/Py8iRJEyZM0IoVK1RZWemLFklKSUlRUVGRpk+frueff16JiYl67rnneGsyAAA4JYc5/spWi9XW1srlcsnj8SgmJqZNb7vfzHVB7/vtvDFtOBMAAEJLW/z95rt+AACAtQgVAABgLUIFAABYi1ABAADWIlQAAIC1CBUAAGAtQgUAAFiLUAEAANYiVAAAgLUIFQAAYC1CBQAAWItQAQAA1iJUAACAtQgVAABgLUIFAABYi1ABAADWIlQAAIC1CBUAAGAtQgUAAFiLUAEAANYiVAAAgLUIFQAAYC1CBQAAWItQAQAA1iJUAACAtQgVAABgLUIFAABYi1ABAADWIlQAAIC1CBUAAGAtQgUAAFiLUAEAANYiVAAAgLUIFQAAYC1CBQAAWItQAQAA1iJUAACAtQgVAABgLUIFAABYi1ABAADWIlQAAIC1CBUAAGAtQgUAAFgrqFBZvHixUlJSFB0dLbfbrS1btpx0+1WrVmnw4ME666yzlJCQoLvuuksHDx4MasIAACB8BBwqhYWFmjZtmmbNmqXS0lJlZGQoKytL5eXlLW6/detW5eTkaNKkSdq1a5def/11ffzxx5o8efJpTx4AAIS2gENlwYIFmjRpkiZPnqyBAwdq4cKFSkpK0pIlS1rc/qOPPlK/fv00depUpaSk6Morr9S9996r7du3n/bkAQBAaAsoVOrr61VSUqLMzEy/8czMTG3btq3FfdLT0/Xdd9+pqKhIxhh9//33+uc//6kxY8ac8H68Xq9qa2v9LgAAIPwEFCo1NTVqbGxUXFyc33h
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.hist(frame0_absdiff.flat, bins=30);"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-2e5d36068fff4d1d",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"We want to find a threshold for this \"absolute difference image\" which will separate the fly from the background. From frame to frame the background changes very little - only noise in the light levels, camera sensor and caused by lossy compression to a movie format cause changes. But when the fly moves over the background, there is a large change in luminance values. This happens only in very few pixels. So few that they do not show on the histogram. However, matplotlib will automatically scale the axes, so we know there must be few pixels with values at 150 or above."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-d05a54e4c069f9aa",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"## Questions Part A\n",
|
||
|
"\n",
|
||
|
"Enter a threshold below and describe why you chose this value. Put your answer in the variable `threshold`."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-1ef3868b1b1b045c",
|
||
|
"locked": false,
|
||
|
"schema_version": 3,
|
||
|
"solution": true
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Type your answer here and then run this and the following cell.\n",
|
||
|
"threshold = 100"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": true,
|
||
|
"grade_id": "cell-c848bbfece87e521",
|
||
|
"locked": false,
|
||
|
"points": 1,
|
||
|
"schema_version": 3,
|
||
|
"solution": true
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"(Here you should describe why you chose your particular threshold value.)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": true,
|
||
|
"grade_id": "cell-edadac5626867908",
|
||
|
"locked": true,
|
||
|
"points": 1,
|
||
|
"schema_version": 3,
|
||
|
"solution": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# If this runs without error, it means the answer in your previous cell was a number.\n",
|
||
|
"assert(threshold+0==threshold)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-f6fc50107a0d129a",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Now we want to \"binarize\" or \"threshold\" the image so that it is all zeros and ones (or true and false). This will let use use analyses like connected components labeling later."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-fcef9de824e56bd5",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAhkAAAGTCAYAAACF2QCoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA0RUlEQVR4nO3de3TU9Z3/8deQyyRgMkqyZEiJGLZppQathorcCgqEcpWlLSgWsEWXLDdjwAvSKnLWpNIVWaWgWBQsUjhtodI9KSW0GmTBCiGx3Fa62ywJNDGFjZNwMZeZz+8PZH4OCUgyM99kZp6Pcz7nNJ/5fOf7+WA1b96fm80YYwQAABBgXTq6AwAAIDwRZAAAgKAgyAAAAEFBkAEAAIKCIAMAAAQFQQYAAAgKggwAABAUBB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xok6ePBno7gIAYCm3bH6XUBHwIKO4uFhz587V+++/r6KiIjU3Nys7O1vnzp3ztlm+fLlWrFihVatWaf/+/XI6nRo1apTq6+u9bXJzc7Vt2zZt3rxZe/bs0dmzZzV+/Hi53e5AdxkAAMt4jL9Hi3f0CK5dwNdk7Nixw+fnN954Qz169FBJSYm++c1vyhijlStXasmSJZo8ebIkacOGDUpJSdGmTZs0e/ZsuVwurVu3Tj//+c81cuRISdLGjRuVlpamXbt2afTo0YHuNgAACLCgr8lwuVySpO7du0uSysvLVV1d7XMbnN1u17Bhw7y3wZWUlKipqcmnTWpqqjIzM694Y1xDQ0OLG+kAAOhsPJ8t/PS
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"binarized = ensure_dtype_uint8(frame0_absdiff>threshold)\n",
|
||
|
"plt.imshow(binarized);\n",
|
||
|
"plt.colorbar();"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-0338555f51c06105",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Now we will use **connected components labeling** via the `ndimage.label()` function.\n",
|
||
|
"\n",
|
||
|
"We will do more with **connected components labeling** later. For now, you can [read about connected components labeling](https://en.wikipedia.org/wiki/Connected-component_labeling).\n",
|
||
|
"\n",
|
||
|
"We will use these labels to perform object detection. We will not bother to detect the fly on every single frame. Only on the frames where we have exactly one label do we say that we detected the fly. We skip the other frames, ignoring them."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-9dae893dac3022a4",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAhkAAAGTCAYAAACF2QCoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA0xUlEQVR4nO3de3TU9Z3/8deQyyTEZJREMoxGDLvpSg1aDYqAFBQIIpeydgstFrDFLlkQDBG5lP4UOTURugKrCIpFURHhtIqle7KWUN0oCxaMieXWardZEjQxhcZJojGXyef3BzI6BDDJzHyTmXk+zvmeYz7z+X6/n09U5s37c7MZY4wAAAACrFd3NwAAAIQnggwAABAUBBkAACAoCDIAAEBQEGQAAICgIMgAAABBQZABAACCgiADAAAEBUEGAAAICoIMAAAQFAQZAACEuTfffFOTJk2Sy+WSzWbTq6+++rX3FBcXKysrS3FxcRowYICefPLJTr+XIAMAgDD36aef6tprr9X69es7VL+8vFy33367RowYodLSUv30pz/VggUL9PLLL3fqvTYOSAMAIHLYbDbt3LlTU6ZMOW+dJUuWaNeuXTp27Ji3LCcnR++9957279/f4XdF+9NQAADQcZ9//rmam5v9fo4xRjabzafMbrfLbrf7/WxJ2r9/v7Kzs33Kxo0bp82bN6ulpUUxMTEdeg5BBgAAFvj88891aXy8GgLwrIsuukgNDb5PevDBB7VixYoAPF2qrq5WamqqT1lqaqpaW1t18uRJ9evXr0PPIcgAAMACzc3NapB0vyR/8g1Nkn7R0KDKykolJSV5ywOVxTjj7EzJmdkVZ5dfCEEGAAAWskuKC8BzkpKSfIKMQHI6naqurvYpq6mpUXR0tJKTkzv8HIIMAAAsFPPF1VWeQDXkAoYOHarf/va3PmW7d+/W4MGDOzwfQ2IJKwAA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J3uMTT+Vvy8vI0Y8YMDR48WEOHDtWmTZtUUVGhnJwcSdKyZcv04Ycf6vnnn5ckTZo0ST/5yU+0ceNG73BJbm6ubrzxRrlcrg6/lyADAAArdUOQMW3aNJ06dUorV65UVVWVMjMzVVhYqP79+0uSqqqqfPbMuOuuu1RfX6/169frvvvu08UXX6xbb71Vq1at6tR7baYzeY8QUldXJ4fDIWmppAtPhgEARLomSY/I7XZ3aJ5DV5z5XnLnSkl+fC3VNUmOdQpqWwOFTAYAAFby96h3f+61GEEGAABW6obhku7C6hIAABAUAQ8yCgoKdMMNNygxMVF9+/bVlClT9Oc//9mnjjFGK1askMvlUnx8vEaNGqUjR4741GlqatL8+fOVkpKihIQETZ48WSdOnAh0cwEAsNaZo967eoXQcEnAg4zi4mLNmzdPb7/9toqKitTa2qrs7Gx9+umn3jqrV6/WmjVrtH79eh08eFBOp1Njx45VfX29t05ubq527typ7du3a+/evWpoaNDEiRPl8YRQnggAgLN1wwFp3SXoq0v+9re/qW/fviouLta3v/1tGWPkcrmUm5urJUuWSDqdtUhNTdWqVas0Z84cud1uXXrppXrhhRc0bdo0SdJHH32ktLQ0FRYWaty4cV/7XlaXAAA6zsLVJQ9ISXF+POdzybEyNFaXBH1OhtvtliT16dNHklReXq7q6mqf0+DsdrtGjhzpPQ2upKRELS0tPnVcLpcyMzPPe2JcU1NTuxPpAADocaICcIWIoAYZxhjl5eXp5ptvVmZmpiR5906/0Glw1dXVio2N1SWXXHLeOmcrKCjwOY0uLS0t0N0BAMB/ETRcEtQg45577tEf//hHvfTSS+0+68xpcB2ps2zZMrndbu9VWVnZ9YYDABAsBBn+mz9/vnbt2qU33nhDl19
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"labels, num_labels = ndimage.label(binarized)\n",
|
||
|
"plt.imshow(labels, cmap='jet')\n",
|
||
|
"plt.colorbar();"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-bf4c1b87ad01a8bb",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"## Questions Part B\n",
|
||
|
"\n",
|
||
|
"Run the object detection algorithm for each frame and plot the result. Here, we are going to make lists `frames`, `xs`, `ys` to save the results of our object detection step.\n",
|
||
|
"\n",
|
||
|
"Try re-running the above cells (from \"Questions Part A\") to the cell below with varying values of the `threshold` value until you get a good tracking result. You should ideally have zero warnings printed, but one or two are OK. "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-cb7ec6b50e3d024a",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"WARNING: num_labels 2 on frame 93, skipping\n",
|
||
|
"WARNING: num_labels 2 on frame 94, skipping\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"frames = []\n",
|
||
|
"xs = []\n",
|
||
|
"ys = []\n",
|
||
|
"for i in range(n_frames):\n",
|
||
|
" frame = all_frames[i,:,:]\n",
|
||
|
" frame_absdiff = abs(frame - median_frame)\n",
|
||
|
" binarized = ensure_dtype_uint8(frame_absdiff>threshold)\n",
|
||
|
" labels, num_labels = ndimage.label(binarized)\n",
|
||
|
" if num_labels!=1:\n",
|
||
|
" print('WARNING: num_labels %d on frame %d, skipping' % (num_labels,i))\n",
|
||
|
" continue\n",
|
||
|
" y,x = np.mean(np.nonzero(labels==1),axis=1)\n",
|
||
|
" frames.append(i)\n",
|
||
|
" xs.append(x)\n",
|
||
|
" ys.append(y)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-c1e4e9b97c4899cb",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Make with an image of the first frame (saved in the variable `frame0` above) in the background and then the fly trajectory overlaid on top of the image.\n",
|
||
|
"\n",
|
||
|
"You can do this by first calling `plt.imshow()` and then `plt.plot()`. Your result should look like this:\n",
|
||
|
"\n",
|
||
|
"<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbAAAAEgCAYAAADVKCZpAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz%0AAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0%0AdHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOy9aZBd13ktts6d57HnCUMDaKBBAoQ5%0AiYxkk6ZoORUNiZVSKbETVWyH75WqkjhKqiJH+ZEfiUX7xS7LsRI/VrlctF02E6cc07L0JDOaXKJF%0AgSJBkARBoIFuoOe5b995vvnRWru/s/vc2w2Q3QCMvaq6uvveM+xzzj7fuL5vW61WqwUDAwMDA4N7%0ADK47PQADAwMDA4PbgVFgBgYGBgb3JIwCMzAwMDC4J2EUmIGBgYHBPQmjwAwMDAwM7kkYBWZgYGBg%0AcE/CKDADAwMDg3sSRoEZGBgYGNyTMArMwMDAwOCehFFgBgYGBgb3JIwCMzAwMDC4J2EUmIGBgYHB%0APQmjwAwMDAwM7kkYBWZgYGBgcE/CKDADAwMDg3sSRoEZGBgYGNyTMArMwMDAwOCehFF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6VS+9%0AMH0qWZaFarWK6elpNBoN5PN51Ot1+P1+HDp0SAlhr9eLfD6PfD6Prq4uRaSgN0WBEQgElFfTarVQ%0AqVQQCASQTqdteS/pKehhKRl27PQcpBJ3+o5jkqFWeX4KeMuy1LWtr6+j1Wohn88jEonYngXzby6X%0AC5OTkygWiyiVSvB6vTh8+LBNaYXD
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 18,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": true,
|
||
|
"grade_id": "cell-7250d526d95bf828",
|
||
|
"locked": false,
|
||
|
"points": 1,
|
||
|
"schema_version": 3,
|
||
|
"solution": true
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAg8AAAGiCAYAAABgTyUPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9eZBs23XeB345VGVlZWZl1lx3eg8PEyU2yA4KVFCEZJEiCMhs0RoY3ZRMtmyFZYtqUaBgSOEwg/+QjmgizAiTDJKWWmTTkkJsBOWOaFp2t5rNR8qCRENwo2HJIqkIAATecO+7Q81VOVdO/Ufht+s7q069AXgPuFUvV8SNW5V18px99rDWt7619tqF2Ww201zmMpe5zGUuc5nL65Ti17sBc5nLXOYyl7nM5XrJHDzMZS5zmctc5jKXNyRz8DCXucxlLnOZy1zekMzBw1zmMpe5zGUuc3lDMgcPc5nLXOYyl7nM5Q3JHDzMZS5zmctc5jKXNyRz8DCXucxlLnOZy1zekMzBw1zmMpe5zGUuc3lDMgcPc5nLXOYyl7nM5Q3JHDzMZS5zmctc5jKXNyRPPXj423/7b+u5557T0tKS3v/+9+tf/It/8fVu0lzmMpe5zGUub2t5qsHD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iO+9MsJycnWllZedVrnmrm4c0QFqEbkDz6lUUADRwlGtZI7frzokTWISoBDwFEijcaS39+nIixTXn5BD6BHdB4EqErZN4JxRYVNYAieoKe9extc3DjXhN/iwbMWaD4fq6oi8Vipn2eke4sCv2St4h5RwcYKKl+v5+AJUlZDhQwFBjWpaWlBBB8bkXgkDeHfPzz5hO
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Type your answer here\n",
|
||
|
"plt.imshow(frame0,cmap='gray');\n",
|
||
|
"plt.plot(xs,ys,'x');"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": false,
|
||
|
"grade_id": "cell-06fde843bcd5b77e",
|
||
|
"locked": true,
|
||
|
"schema_version": 3,
|
||
|
"solution": false,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"Make a plot of the timeseries of the x and y values.\n",
|
||
|
"\n",
|
||
|
"We want a plot that looks like the following. You need to fix the following code to do this:\n",
|
||
|
"\n",
|
||
|
"```\n",
|
||
|
"fig, axes = plt.subplots(nrows=2, ncols=1, sharex=True)\n",
|
||
|
"axes[0].plot(time_values,x_values,'x')\n",
|
||
|
"axes[0].set_ylabel('x (px)')\n",
|
||
|
"axes[1].plot(time_values,y_values,'x')\n",
|
||
|
"axes[1].set_ylabel('y (px)')\n",
|
||
|
"axes[1].set_xlabel('time (frames)')\n",
|
||
|
"```\n",
|
||
|
"\n",
|
||
|
"As a side note, the `sharedx` links the two panels together so they have the same X axis. When using matplotlib interactively (highly recommended!!!), panning and zooming in one panel also pans and zooms the other panel. This is incredibly useful.\n",
|
||
|
"\n",
|
||
|
"<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYA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zfvVFV7DvheQzgMnJyXK5XDX+TJs2%0ATZI0ceLEGq8NHDjQ7RwVFRW655571KlTJ7Vt21Y33HCDvvzyy0B8HQAIaZ6eVzP3rdhcpKW5hW7H%0AmPtMzu3mzgx85v0wn9lbkltoPedmH/aMioywhn3N8GcKpef9zoanrmA0rZCsAG7fvl1VVVXW9q5d%0Au5SRkaHRo0db+6677jplZ2db21FRUW7nmDFjht58803l5OQoLi5Os2bN0siRI1VQUKDIyEjffwkA%0A8LPaJhNuTIelp+fV7PvM5byW5BZq697j1rJk5ucG65Jfzvtl33beL/s8e857vNTWvGB/j3k/BiR3%0AdGtusE+GLKnO6VGaW3XM+cxfcxjqDkYhGQDPPfdct+3FixerZ8+eGjRokLUvOjpa8fHxHt9fWlqq%0A1atX64UXXtCQIUMkSevWrVNSUpLy8vI0bNgw3108APiBp7BnhjIzdMxsYAhznts+FOkp0JjHmOHP%0AXJbs1pUfauveEx6f7/L1lB/1CXfO+2XfNkPs0txCbd9/wi3UOodzPYVh+/34aO8JVRlnmiHsw57m%0AucIpCHlq+GjOQ92BFJIB0K6yslLr1q1TVlaWXK4f/4Xz7rvvqnPnzmrfvr0GDRqkRx99VJ07d5Yk%0AFRQU6PTp0xo6dKh1fGJionr37q38/HyvAbCiokIVFRXWdllZmY++FQA0jqeqnD10mOrqsKxvkPQW%0AaCT3eevSesYpv/i4UudutOaxc36W
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": true,
|
||
|
"grade_id": "cell-8680c2c7c9c5cb22",
|
||
|
"locked": false,
|
||
|
"points": 1,
|
||
|
"schema_version": 3,
|
||
|
"solution": true,
|
||
|
"task": false
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Text(0.5, 0, 'time (frames)')"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjsAAAGyCAYAAAACgQXWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABawElEQVR4nO3dfVxUZd4/8M8wAooBCigwSSIGtYoVoqtS92IhmmnuruVDmOlqpFuKiPZAbuvDpqi9VtSsNlkX24xo29StTXcFKtMfkixZK7YrCD5gylJIgKs70Mz5/UHneObMGZiBGeaBz/v14nU7Zy4O15zd+57v/f1+r+vSCIIggIiIiMhDeTl7AkRERESOxGCHiIiIPBqDHSIiIvJoDHaIiIjIozHYISIiIo/GYIeIiIg8GoMdIiIi8mgMdoiIiMijMdghIiIij9bL2RNwBUajEZcuXYK/vz80Go2zp0NERERWEAQBzc3N0Ol08PJqJ38jONHgwYMFAGY/Tz75pPDDMRaqP5s3b5bukZiYaPb+rFmzbJpHTU2Nxb/FH/7whz/84Q9/XPunpqam3e95p2Z2SktLYTAYpNfl5eVITk7GjBkzAACXL182GX/w4EEsXLgQDz30kMn11NRUrFu3Tnrdp08fm+bh7+8PAKipqUFAQIBNv0tERETO0dTUhIiICOl73BKnBjsDBgwweb1x40YMHToUiYmJAICwsDCT9//yl7/g3nvvRVRUlMl1Pz8/s7G2EEtXAQEBDHaIiIjcTEctKC7ToNzS0oI9e/ZgwYIFqpP+z3/+gw8//BALFy40e++tt95CSEgIhg8fjpUrV6K5ubndv6XX69HU1GTyQ0RERJ7JZRqU9+/fj++++w7z589Xff+NN96Av78/pk+fbnJ9zpw5GDJkCMLCwlBeXo7MzEx8+eWXKCgosPi3srKysHbtWntOn4iIyOVlF1RA66VBWlK02evtRZUwGAUsT44BALPX7sxlgp1du3Zh8uTJ0Ol0qu//4Q9/wJw5c9C7d2+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X5NnM+WggqTIE75udXGJAwNMRmjfBYxqw5KTbhioGNpWbn873liwKN2WCjgvHKdy/TstLS0YM+ePcjIyIBGcyMN+sknn2DgwIHo168fEhMTsX79egwcOBAAUFZWhtbWVkycOFEar9PpEBsbi+LiYovBjl6vh16vl143NTU56FMREXVNRydil1RfMfmStfTFaW3QJKfMTCj/jvha/EIX+zHEc5zU5mNLtkf52cXX7QUpagGbkjw7JQ/ibBmjPPtJfBbi6eTyPhV3X1beGe3959ujV2Pt378f3333HebPny9dmzx5MmbMmIHBgwfj7NmzeOGFF3DfffehrKwMvr6+qK2thY+PD/r3729yr9DQUNTW1lr8W1lZWVi7dq2jPgoRkd20d7yAMoPQXtOwrUGTfAVNXupYky9zcQ7KL3TlIZYieRlJnLc1paXlsmBGDMY6ClKU5EGJeK/2gjhrxihXFymfhTzD5gnLyj2BywQ7u3btwuTJk6HT6aRrs2bNkv4dGxuLUaNGYfDgwfjwww8xffp0i/cSBMEkO6SUmZmJjIwM6XVTUxMiIiK6+AmIiBzD0mnSAKRAxyAISMkpkVb5WOqlETMjoyODpABI+QUu3lf88k7JKTF7rdaDIu4I7KP1wpL7bpWCK2UZSdm30l5pSSQPxqwJUtSCEgAdBnEdjVF7NmpZJrX/7OSvqXu5xHER58+fR2FhIR5//PF2x4WHh2Pw4MGorGyL5MPCwtDS0oKGhgaTcXV1dQgNDbV4H19fXwQEBJj8EBG5AmuOFxC/dMVApSrrASkASMkpAQAp0JGXUNKSoqVxOz46Y9JTo5aZqFg/WRqfMDTY7LXyvuKyavmp3WIA0hH
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"fig, axes = plt.subplots(nrows=2, ncols=1, sharex=True)\n",
|
||
|
"axes[0].plot(frames,xs,'x')\n",
|
||
|
"axes[0].set_ylabel('x (px)')\n",
|
||
|
"axes[1].plot(frames,ys,'x')\n",
|
||
|
"axes[1].set_ylabel('y (px)')\n",
|
||
|
"axes[1].set_xlabel('time (frames)')\n",
|
||
|
"# plt.savefig('fly-tracking2.png')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Questions Part C\n",
|
||
|
"\n",
|
||
|
"Describe: How did we get the background image? How did we compute a binary image? What did we do with the binary image?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"nbgrader": {
|
||
|
"grade": true,
|
||
|
"grade_id": "cell-0a341a483941e5cd",
|
||
|
"locked": false,
|
||
|
"points": 2,
|
||
|
"schema_version": 3,
|
||
|
"solution": true
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"(Answer here.)"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"celltoolbar": "Create Assignment",
|
||
|
"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.11.10"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 4
|
||
|
}
|