Commit e1f14385 authored by Bryce Hepner's avatar Bryce Hepner

probably testing, not sure what changed

parent 56f3f0fc
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 95,
"execution_count": 1,
"id": "14f74f21",
"metadata": {},
"outputs": [],
......@@ -14,18 +14,17 @@
"import sys\n",
"from PIL import Image\n",
"from scipy.optimize import minimize,linprog\n",
"import time\n",
"import seaborn as sns\n",
"# import time\n",
"# import seaborn as sns\n",
"from sklearn.neighbors import KernelDensity\n",
"import pandas as pd\n",
"# import pandas as pd\n",
"from collections import Counter\n",
"import time\n",
"import numpy.linalg as la"
]
},
{
"cell_type": "code",
"execution_count": 96,
"execution_count": 2,
"id": "c16af61f",
"metadata": {},
"outputs": [],
......@@ -78,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 97,
"execution_count": 3,
"id": "53786325",
"metadata": {},
"outputs": [],
......@@ -154,7 +153,7 @@
},
{
"cell_type": "code",
"execution_count": 98,
"execution_count": 4,
"id": "6b965751",
"metadata": {},
"outputs": [],
......@@ -210,7 +209,7 @@
},
{
"cell_type": "code",
"execution_count": 99,
"execution_count": 5,
"id": "b7561883",
"metadata": {},
"outputs": [],
......@@ -319,7 +318,7 @@
},
{
"cell_type": "code",
"execution_count": 100,
"execution_count": 6,
"id": "2eb774d2",
"metadata": {},
"outputs": [],
......@@ -359,7 +358,7 @@
},
{
"cell_type": "code",
"execution_count": 101,
"execution_count": 7,
"id": "8eeb40d0",
"metadata": {},
"outputs": [],
......@@ -403,7 +402,7 @@
" # if it's the very first pixel on the image\n",
" if i == 0 and j == 0:\n",
" decode_matrix[i][j] = int(the_keys0[the_values0.index(encoded_matrix[i,j])])\n",
" # if it's on the boundary\n",
" # if it's on the boundary (any of the 4 edges)\n",
" elif i == 0 or i == decode_matrix.shape[0]-1 or j == 0 or j == decode_matrix.shape[1]-1:\n",
" decode_matrix[i][j] = int(the_keys0[the_values0.index(encoded_matrix[i,j])]) + decode_matrix[0][0]\n",
" # if not the boundary\n",
......@@ -443,7 +442,7 @@
},
{
"cell_type": "code",
"execution_count": 102,
"execution_count": 15,
"id": "f959fe93",
"metadata": {},
"outputs": [],
......@@ -501,13 +500,13 @@
"\n",
" else: \n",
" c_len += len(huffman_encoding_list[4][str(int(error[i]))])\n",
"\n",
" \n",
" return c_len/o_len"
]
},
{
"cell_type": "code",
"execution_count": 103,
"execution_count": 12,
"id": "3e0e9742",
"metadata": {},
"outputs": [
......@@ -532,7 +531,7 @@
},
{
"cell_type": "code",
"execution_count": 104,
"execution_count": 16,
"id": "004e8ba8",
"metadata": {},
"outputs": [
......@@ -542,7 +541,7 @@
"0.4232928466796875"
]
},
"execution_count": 104,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
......@@ -573,9 +572,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"id": "7efe26b9",
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "Cannot handle this data type: (1, 1), |O",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"File \u001b[0;32m~/.local/lib/python3.8/site-packages/PIL/Image.py:2928\u001b[0m, in \u001b[0;36mfromarray\u001b[0;34m(obj, mode)\u001b[0m\n\u001b[1;32m <a href='file:///~/.local/lib/python3.8/site-packages/PIL/Image.py?line=2926'>2927</a>\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m-> <a href='file:///~/.local/lib/python3.8/site-packages/PIL/Image.py?line=2927'>2928</a>\u001b[0m mode, rawmode \u001b[39m=\u001b[39m _fromarray_typemap[typekey]\n\u001b[1;32m <a href='file:///~/.local/lib/python3.8/site-packages/PIL/Image.py?line=2928'>2929</a>\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mKeyError\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n",
"\u001b[0;31mKeyError\u001b[0m: ((1, 1), '|O')",
"\nThe above exception was the direct cause of the following exception:\n",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/home/bryce/git/master/Encoding_decoding.ipynb Cell 12'\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> <a href='vscode-notebook-cell:/home/bryce/git/master/Encoding_decoding.ipynb#ch0000011?line=0'>1</a>\u001b[0m compressed_image \u001b[39m=\u001b[39m Image\u001b[39m.\u001b[39;49mfromarray(encoded_matrix)\n\u001b[1;32m <a href='vscode-notebook-cell:/home/bryce/git/master/Encoding_decoding.ipynb#ch0000011?line=1'>2</a>\u001b[0m compressed_image\u001b[39m.\u001b[39msave(\u001b[39m\"\u001b[39m\u001b[39mHuffmanedTry1.tiff\u001b[39m\u001b[39m\"\u001b[39m)\n",
"File \u001b[0;32m~/.local/lib/python3.8/site-packages/PIL/Image.py:2930\u001b[0m, in \u001b[0;36mfromarray\u001b[0;34m(obj, mode)\u001b[0m\n\u001b[1;32m <a href='file:///~/.local/lib/python3.8/site-packages/PIL/Image.py?line=2927'>2928</a>\u001b[0m mode, rawmode \u001b[39m=\u001b[39m _fromarray_typemap[typekey]\n\u001b[1;32m <a href='file:///~/.local/lib/python3.8/site-packages/PIL/Image.py?line=2928'>2929</a>\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mKeyError\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n\u001b[0;32m-> <a href='file:///~/.local/lib/python3.8/site-packages/PIL/Image.py?line=2929'>2930</a>\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mTypeError\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39mCannot handle this data type: \u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m, \u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m\"\u001b[39m \u001b[39m%\u001b[39m typekey) \u001b[39mfrom\u001b[39;00m \u001b[39me\u001b[39;00m\n\u001b[1;32m <a href='file:///~/.local/lib/python3.8/site-packages/PIL/Image.py?line=2930'>2931</a>\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m <a href='file:///~/.local/lib/python3.8/site-packages/PIL/Image.py?line=2931'>2932</a>\u001b[0m rawmode \u001b[39m=\u001b[39m mode\n",
"\u001b[0;31mTypeError\u001b[0m: Cannot handle this data type: (1, 1), |O"
]
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "b46343b2",
"metadata": {},
"outputs": [],
"source": []
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment