From e450335467908556c2c38c1b867239c6574528d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Parafin=CC=81ski?= Date: Tue, 17 May 2022 22:28:19 +0200 Subject: [PATCH] fix printing matrixes --- jupyter.ipynb | 168 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 119 insertions(+), 49 deletions(-) diff --git a/jupyter.ipynb b/jupyter.ipynb index 303c1dc..59126f4 100644 --- a/jupyter.ipynb +++ b/jupyter.ipynb @@ -2,9 +2,10 @@ "cells": [ { "cell_type": "code", - "execution_count": 18, + "execution_count": 23, "metadata": { "pycharm": { + "is_executing": true, "name": "#%%\n" } }, @@ -13,21 +14,24 @@ "name": "stderr", "output_type": "stream", "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" ] }, { "data": { - "text/plain": "", - "text/html": "" + "text/html": [ + "" + ], + "text/plain": [ + "" + ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ - "import IPython\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from skimage import data\n", @@ -44,7 +48,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 46, "metadata": { "pycharm": { "name": "#%%\n" @@ -110,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 24, "metadata": { "pycharm": { "name": "#%%\n" @@ -153,7 +157,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 25, "metadata": { "pycharm": { "name": "#%%\n" @@ -185,7 +189,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 26, "metadata": { "pycharm": { "name": "#%%\n" @@ -224,7 +228,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 27, "metadata": { "pycharm": { "name": "#%%\n" @@ -254,7 +258,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 28, "metadata": { "pycharm": { "name": "#%%\n" @@ -287,8 +291,9 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 29, "metadata": { + "collapsed": true, "pycharm": { "name": "#%%\n" } @@ -296,21 +301,25 @@ "outputs": [ { "data": { - "text/plain": "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'camera', 'coin', 'clock', 'te…", "application/vnd.jupyter.widget-view+json": { + "model_id": "aca9f364d54e4861a5e74c0d8f1c90a4", "version_major": 2, - "version_minor": 0, - "model_id": "e73d6e563a63469e9a4b9f32a01b7187" - } + "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": "" + "text/plain": [ + "" + ] }, - "execution_count": 25, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -321,8 +330,9 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 30, "metadata": { + "collapsed": true, "pycharm": { "name": "#%%\n" } @@ -330,12 +340,14 @@ "outputs": [ { "data": { - "text/plain": "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'camera', 'coin', 'clock', 'te…", "application/vnd.jupyter.widget-view+json": { + "model_id": "4182f0c1306b4ad0906069edd805e512", "version_major": 2, - "version_minor": 0, - "model_id": "5a74237c02e040abb124f54625d61846" - } + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'camera', 'coin', 'clock', 'te…" + ] }, "metadata": {}, "output_type": "display_data" @@ -358,7 +370,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 31, "metadata": { "pycharm": { "name": "#%%\n" @@ -415,7 +427,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 32, "metadata": { "pycharm": { "name": "#%%\n" @@ -450,7 +462,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 33, "metadata": { "pycharm": { "name": "#%%\n" @@ -474,7 +486,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 48, "metadata": { "pycharm": { "name": "#%%\n" @@ -483,33 +495,38 @@ "outputs": [ { "data": { - "text/plain": "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…", "application/vnd.jupyter.widget-view+json": { + "model_id": "a2e35d368db94f6caad9954bd64c5a58", "version_major": 2, - "version_minor": 0, - "model_id": "46b3c56fd85e40b299d36dd0c1630c9f" - } + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Dropdown(description='img_name', index=5, options=('cat', 'astro', 'coffee', 'rocket', '…" + ] }, "metadata": {}, "output_type": "display_data" }, { "data": { - "text/plain": "" + "text/plain": [ + "" + ] }, - "execution_count": 30, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "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", - "execution_count": 31, + "execution_count": 35, "metadata": { + "collapsed": true, "pycharm": { "name": "#%%\n" } @@ -517,12 +534,14 @@ "outputs": [ { "data": { - "text/plain": "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…", "application/vnd.jupyter.widget-view+json": { + "model_id": "a86d9cbb5cd64ea0bf777d5d16e7f534", "version_major": 2, - "version_minor": 0, - "model_id": "b5123a5d03fb489699824a8415bc6701" - } + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…" + ] }, "metadata": {}, "output_type": "display_data" @@ -556,7 +575,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 39, "metadata": { "pycharm": { "name": "#%%\n" @@ -571,7 +590,7 @@ " 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)\n", + "# print(image_reconst_layers)\n", " image_reconst = np.zeros(image.shape)\n", " for i in range(3):\n", " image_reconst[:,:,i] = image_reconst_layers[i]\n", @@ -581,6 +600,22 @@ " 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", "metadata": { @@ -594,7 +629,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 40, "metadata": { "pycharm": { "name": "#%%\n" @@ -618,7 +653,33 @@ }, { "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": { "pycharm": { "name": "#%%\n" @@ -627,12 +688,14 @@ "outputs": [ { "data": { - "text/plain": "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…", "application/vnd.jupyter.widget-view+json": { + "model_id": "6cb1ac93975744a4aa20838d6442c5a2", "version_major": 2, - "version_minor": 0, - "model_id": "14cf5f5b31f74c2482088989f5e87558" - } + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Dropdown(description='img_name', options=('cat', 'astro', 'coffee', 'rocket', 'koala', '…" + ] }, "metadata": {}, "output_type": "display_data" @@ -641,6 +704,13 @@ "source": [ "interact(compress_show_color_images_layer,img_name=list_widget,k=int_slider_widget);" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -659,9 +729,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.13" + "version": "3.8.9" } }, "nbformat": 4, "nbformat_minor": 1 -} \ No newline at end of file +}