fix printing matrixes
This commit is contained in:
parent
5fee55f1c5
commit
e450335467
168
jupyter.ipynb
168
jupyter.ipynb
@ -2,9 +2,10 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 18,
|
"execution_count": 23,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
|
"is_executing": true,
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -13,21 +14,24 @@
|
|||||||
"name": "stderr",
|
"name": "stderr",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"/var/folders/t3/dwnz0lh916ng4w7bzf0z56ym0000gn/T/ipykernel_32034/3285565865.py:11: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display\n",
|
"/var/folders/8w/3c34c7kd2n144tvm764_pdbw0000gq/T/ipykernel_56318/3079151100.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"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": "<IPython.core.display.HTML object>",
|
"text/html": [
|
||||||
"text/html": "<style>.container { width:80% !important; }</style>"
|
"<style>.container { width:80% !important; }</style>"
|
||||||
|
],
|
||||||
|
"text/plain": [
|
||||||
|
"<IPython.core.display.HTML object>"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "display_data"
|
"output_type": "display_data"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"import IPython\n",
|
|
||||||
"import numpy as np\n",
|
"import numpy as np\n",
|
||||||
"import matplotlib.pyplot as plt\n",
|
"import matplotlib.pyplot as plt\n",
|
||||||
"from skimage import data\n",
|
"from skimage import data\n",
|
||||||
@ -44,7 +48,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 19,
|
"execution_count": 46,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -110,7 +114,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 20,
|
"execution_count": 24,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -153,7 +157,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 21,
|
"execution_count": 25,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -185,7 +189,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 22,
|
"execution_count": 26,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -224,7 +228,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 23,
|
"execution_count": 27,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -254,7 +258,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 24,
|
"execution_count": 28,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -287,8 +291,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 25,
|
"execution_count": 29,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"collapsed": true,
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
@ -296,21 +301,25 @@
|
|||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'camera', 'coin', 'clock', 'te…",
|
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
"application/vnd.jupyter.widget-view+json": {
|
||||||
|
"model_id": "aca9f364d54e4861a5e74c0d8f1c90a4",
|
||||||
"version_major": 2,
|
"version_major": 2,
|
||||||
"version_minor": 0,
|
"version_minor": 0
|
||||||
"model_id": "e73d6e563a63469e9a4b9f32a01b7187"
|
},
|
||||||
}
|
"text/plain": [
|
||||||
|
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'camera', 'coin', 'clock', 'te…"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "display_data"
|
"output_type": "display_data"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": "<function __main__.print_matrices(img_name, k)>"
|
"text/plain": [
|
||||||
|
"<function __main__.print_matrices(img_name, k)>"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 25,
|
"execution_count": 29,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@ -321,8 +330,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 26,
|
"execution_count": 30,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"collapsed": true,
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
@ -330,12 +340,14 @@
|
|||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'camera', 'coin', 'clock', 'te…",
|
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
"application/vnd.jupyter.widget-view+json": {
|
||||||
|
"model_id": "4182f0c1306b4ad0906069edd805e512",
|
||||||
"version_major": 2,
|
"version_major": 2,
|
||||||
"version_minor": 0,
|
"version_minor": 0
|
||||||
"model_id": "5a74237c02e040abb124f54625d61846"
|
},
|
||||||
}
|
"text/plain": [
|
||||||
|
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'camera', 'coin', 'clock', 'te…"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "display_data"
|
"output_type": "display_data"
|
||||||
@ -358,7 +370,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 27,
|
"execution_count": 31,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -415,7 +427,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 28,
|
"execution_count": 32,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -450,7 +462,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 29,
|
"execution_count": 33,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -474,7 +486,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 30,
|
"execution_count": 48,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -483,33 +495,38 @@
|
|||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…",
|
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
"application/vnd.jupyter.widget-view+json": {
|
||||||
|
"model_id": "a2e35d368db94f6caad9954bd64c5a58",
|
||||||
"version_major": 2,
|
"version_major": 2,
|
||||||
"version_minor": 0,
|
"version_minor": 0
|
||||||
"model_id": "46b3c56fd85e40b299d36dd0c1630c9f"
|
},
|
||||||
}
|
"text/plain": [
|
||||||
|
"interactive(children=(Dropdown(description='img_name', index=5, options=('cat', 'astro', 'coffee', 'rocket', '…"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "display_data"
|
"output_type": "display_data"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": "<function __main__.print_matrices(img_name, k)>"
|
"text/plain": [
|
||||||
|
"<function __main__.print_color_matrices(img_name, k)>"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 30,
|
"execution_count": 48,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"interact(print_matrices, img_name=list_widget, k=int_slider_widget)"
|
"interact(print_color_matrices, img_name=list_widget, k=int_slider_widget)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 31,
|
"execution_count": 35,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"collapsed": true,
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
}
|
}
|
||||||
@ -517,12 +534,14 @@
|
|||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…",
|
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
"application/vnd.jupyter.widget-view+json": {
|
||||||
|
"model_id": "a86d9cbb5cd64ea0bf777d5d16e7f534",
|
||||||
"version_major": 2,
|
"version_major": 2,
|
||||||
"version_minor": 0,
|
"version_minor": 0
|
||||||
"model_id": "b5123a5d03fb489699824a8415bc6701"
|
},
|
||||||
}
|
"text/plain": [
|
||||||
|
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "display_data"
|
"output_type": "display_data"
|
||||||
@ -556,7 +575,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 32,
|
"execution_count": 39,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -571,7 +590,7 @@
|
|||||||
" image = color_images[img_name]\n",
|
" image = color_images[img_name]\n",
|
||||||
" original_shape = image.shape\n",
|
" original_shape = image.shape\n",
|
||||||
" image_reconst_layers = [compress_svd(image[:,:,i],k)[0] for i in range(3)]\n",
|
" image_reconst_layers = [compress_svd(image[:,:,i],k)[0] for i in range(3)]\n",
|
||||||
" print(image_reconst_layers)\n",
|
"# print(image_reconst_layers)\n",
|
||||||
" image_reconst = np.zeros(image.shape)\n",
|
" image_reconst = np.zeros(image.shape)\n",
|
||||||
" for i in range(3):\n",
|
" for i in range(3):\n",
|
||||||
" image_reconst[:,:,i] = image_reconst_layers[i]\n",
|
" image_reconst[:,:,i] = image_reconst_layers[i]\n",
|
||||||
@ -581,6 +600,22 @@
|
|||||||
" plt.imshow(image_reconst, vmin=0, vmax=255)\n"
|
" plt.imshow(image_reconst, vmin=0, vmax=255)\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 42,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def print_color_matrices(img_name,k):\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" Wyświetlanie macierzy U V S wraz z wymiarami.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" image = color_images[img_name]\n",
|
||||||
|
" original_shape = image.shape\n",
|
||||||
|
" image_reconst_layers = [compress_svd(image[:,:,i],k)[0] for i in range(3)]\n",
|
||||||
|
" print(image_reconst_layers)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@ -594,7 +629,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 33,
|
"execution_count": 40,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -618,7 +653,33 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 34,
|
"execution_count": 43,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"application/vnd.jupyter.widget-view+json": {
|
||||||
|
"model_id": "280c9df9b5c64f9a937c79974567b4f8",
|
||||||
|
"version_major": 2,
|
||||||
|
"version_minor": 0
|
||||||
|
},
|
||||||
|
"text/plain": [
|
||||||
|
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "display_data"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"interact(print_color_matrices,img_name=list_widget,k=int_slider_widget);"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 41,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
@ -627,12 +688,14 @@
|
|||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…",
|
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
"application/vnd.jupyter.widget-view+json": {
|
||||||
|
"model_id": "6cb1ac93975744a4aa20838d6442c5a2",
|
||||||
"version_major": 2,
|
"version_major": 2,
|
||||||
"version_minor": 0,
|
"version_minor": 0
|
||||||
"model_id": "14cf5f5b31f74c2482088989f5e87558"
|
},
|
||||||
}
|
"text/plain": [
|
||||||
|
"interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "display_data"
|
"output_type": "display_data"
|
||||||
@ -641,6 +704,13 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"interact(compress_show_color_images_layer,img_name=list_widget,k=int_slider_widget);"
|
"interact(compress_show_color_images_layer,img_name=list_widget,k=int_slider_widget);"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@ -659,9 +729,9 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.8.13"
|
"version": "3.8.9"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
"nbformat_minor": 1
|
"nbformat_minor": 1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user