teacher jpg added
This commit is contained in:
parent
707400c7ef
commit
28c8b93256
188
jupyter.ipynb
188
jupyter.ipynb
@ -2,7 +2,7 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 18,
|
"execution_count": 1,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -13,7 +13,7 @@
|
|||||||
"name": "stderr",
|
"name": "stderr",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"/var/folders/t3/dwnz0lh916ng4w7bzf0z56ym0000gn/T/ipykernel_20610/17056051.py:11: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display\n",
|
"/var/folders/t3/dwnz0lh916ng4w7bzf0z56ym0000gn/T/ipykernel_26663/17056051.py:11: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display\n",
|
||||||
" from IPython.core.display import display, HTML\n"
|
" from IPython.core.display import display, HTML\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -47,7 +47,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 19,
|
"execution_count": 2,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -113,7 +113,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 20,
|
"execution_count": 3,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -156,7 +156,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 21,
|
"execution_count": 4,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -191,12 +191,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 22,
|
"execution_count": null,
|
||||||
"metadata": {
|
|
||||||
"pycharm": {
|
|
||||||
"name": "#%%\n"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"def compress_show_gray_images(img_name,k):\n",
|
"def compress_show_gray_images(img_name,k):\n",
|
||||||
@ -213,28 +208,31 @@
|
|||||||
" axes[1].set_title(\"compression ratio={:.2f}\".format(compression_ratio)+\"%\")\n",
|
" axes[1].set_title(\"compression ratio={:.2f}\".format(compression_ratio)+\"%\")\n",
|
||||||
" axes[1].imshow(reconst_img,cmap='gray')\n",
|
" axes[1].imshow(reconst_img,cmap='gray')\n",
|
||||||
" axes[1].axis('off')\n",
|
" axes[1].axis('off')\n",
|
||||||
" fig.tight_layout()"
|
" fig.tight_layout()\n",
|
||||||
]
|
" # compression rate = 100% * (k * (height + width + k)) / (height + width)"
|
||||||
},
|
],
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"pycharm": {
|
|
||||||
"name": "#%% md\n"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"W celu zbadania, jak jakość zrekonstruowanego obrazu zmienia się wraz z $k$ należy użyć poniższego interaktywnego widżetu."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 23,
|
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"collapsed": false,
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"source": [
|
||||||
|
"W celu zbadania, jak jakość zrekonstruowanego obrazu zmienia się wraz z $k$ należy użyć poniższego interaktywnego widżetu."
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false,
|
||||||
|
"pycharm": {
|
||||||
|
"name": "#%% md\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"def compute_k_max(img_name):\n",
|
"def compute_k_max(img_name):\n",
|
||||||
@ -256,20 +254,24 @@
|
|||||||
" int_slider_widget.max = compute_k_max(img_name)\n",
|
" int_slider_widget.max = compute_k_max(img_name)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"list_widget.observe(update_k_max,'value')\n"
|
"list_widget.observe(update_k_max,'value')\n"
|
||||||
]
|
],
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 24,
|
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"collapsed": false,
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Print matrices\n",
|
"# Print matrices\n",
|
||||||
"def print_matrices(img_name, k):\n",
|
"def print_matrices(img_name, k):\n",
|
||||||
|
" if (img_name not in gray_images.keys()):\n",
|
||||||
|
" return\n",
|
||||||
|
" \n",
|
||||||
" image=gray_images[img_name]\n",
|
" image=gray_images[img_name]\n",
|
||||||
" original_shape = image.shape\n",
|
" original_shape = image.shape\n",
|
||||||
" print(f\"Input image dimensions. Width:{original_shape[1]} Height:{original_shape[0]}\")\n",
|
" print(f\"Input image dimensions. Width:{original_shape[1]} Height:{original_shape[0]}\")\n",
|
||||||
@ -283,93 +285,57 @@
|
|||||||
" print('*' * 100)\n",
|
" print('*' * 100)\n",
|
||||||
" print(f\"Shape of V matrix: {V[:k,:].shape}\")\n",
|
" print(f\"Shape of V matrix: {V[:k,:].shape}\")\n",
|
||||||
" print(f\"V MATRIX: {V[:k,:]}\")\n"
|
" print(f\"V MATRIX: {V[:k,:]}\")\n"
|
||||||
]
|
],
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 25,
|
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"collapsed": false,
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
|
||||||
"model_id": "97ddd455e9c8432c9d06874ef2d8d4c8",
|
|
||||||
"version_major": 2,
|
|
||||||
"version_minor": 0
|
|
||||||
},
|
|
||||||
"text/plain": [
|
|
||||||
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'camera', 'coin', 'clock', 'te…"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "display_data"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"<function __main__.print_matrices(img_name, k)>"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 25,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"interact(print_matrices, img_name=list_widget, k=int_slider_widget)"
|
"interact(print_matrices, img_name=list_widget, k=int_slider_widget)"
|
||||||
]
|
],
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 26,
|
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"collapsed": false,
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
|
||||||
"model_id": "845d2b4394b04d5681141aac8e9cbc29",
|
|
||||||
"version_major": 2,
|
|
||||||
"version_minor": 0
|
|
||||||
},
|
|
||||||
"text/plain": [
|
|
||||||
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'camera', 'coin', 'clock', 'te…"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "display_data"
|
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"interact(compress_show_gray_images,img_name=list_widget,k=int_slider_widget);"
|
"interact(compress_show_gray_images,img_name=list_widget,k=int_slider_widget);"
|
||||||
]
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false,
|
||||||
|
"pycharm": {
|
||||||
|
"name": "#%%\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
|
"source": [
|
||||||
|
"### Ładowanie kolorowych obrazów"
|
||||||
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"collapsed": false,
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%% md\n"
|
"name": "#%% md\n"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"source": [
|
|
||||||
"### Ładowanie kolorowych obrazów"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 27,
|
"execution_count": null,
|
||||||
"metadata": {
|
|
||||||
"pycharm": {
|
|
||||||
"name": "#%%\n"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"color_images = {\n",
|
"color_images = {\n",
|
||||||
@ -378,9 +344,16 @@
|
|||||||
" \"coffee\":img_as_float(data.coffee()),\n",
|
" \"coffee\":img_as_float(data.coffee()),\n",
|
||||||
" \"rocket\":img_as_float(data.rocket()),\n",
|
" \"rocket\":img_as_float(data.rocket()),\n",
|
||||||
" \"koala\": img_as_float(Image.open('koala.jpeg')),\n",
|
" \"koala\": img_as_float(Image.open('koala.jpeg')),\n",
|
||||||
" \"orange\": img_as_float(Image.open('orange.jpeg'))\n",
|
" \"orange\": img_as_float(Image.open('orange.jpeg')),\n",
|
||||||
"}"
|
" \"teacher\": img_as_float(Image.open('teacher.jpeg'))\n",
|
||||||
]
|
"}\n"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false,
|
||||||
|
"pycharm": {
|
||||||
|
"name": "#%%\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -489,12 +462,12 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
"application/vnd.jupyter.widget-view+json": {
|
||||||
"model_id": "704a0aea9bc64cf991168a250b20c6a7",
|
"model_id": "4715b532b1d64abc9a8451cbfcfcc0e7",
|
||||||
"version_major": 2,
|
"version_major": 2,
|
||||||
"version_minor": 0
|
"version_minor": 0
|
||||||
},
|
},
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'koala', 'orange'), …"
|
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@ -527,12 +500,12 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
"application/vnd.jupyter.widget-view+json": {
|
||||||
"model_id": "a952305f0af44bbb89f18df43a922d7d",
|
"model_id": "f56619fa4fac4a6b9babba92ed3fb72a",
|
||||||
"version_major": 2,
|
"version_major": 2,
|
||||||
"version_minor": 0
|
"version_minor": 0
|
||||||
},
|
},
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'koala', 'orange'), …"
|
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@ -629,10 +602,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 17,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"is_executing": true,
|
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -640,12 +612,12 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
"application/vnd.jupyter.widget-view+json": {
|
||||||
"model_id": "5fcf1a7a0089474db6ae5775db349344",
|
"model_id": "4fa3385da3234652945d611efad33b62",
|
||||||
"version_major": 2,
|
"version_major": 2,
|
||||||
"version_minor": 0
|
"version_minor": 0
|
||||||
},
|
},
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'koala', 'orange'), …"
|
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@ -661,7 +633,6 @@
|
|||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"is_executing": true,
|
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -673,7 +644,6 @@
|
|||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"is_executing": true,
|
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
BIN
teacher.jpeg
Normal file
BIN
teacher.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 91 KiB |
Loading…
Reference in New Issue
Block a user