Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
image-compression
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
image-compression
Commits
e1f14385
Commit
e1f14385
authored
May 27, 2022
by
Bryce Hepner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
probably testing, not sure what changed
parent
56f3f0fc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
18 deletions
+42
-18
Encoding_decoding.ipynb
Encoding_decoding.ipynb
+42
-18
No files found.
Encoding_decoding.ipynb
View file @
e1f14385
...
...
@@ -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": 1
02
,
"execution_count": 1
5
,
"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": 1
03
,
"execution_count": 1
2
,
"id": "3e0e9742",
"metadata": {},
"outputs": [
...
...
@@ -532,7 +531,7 @@
},
{
"cell_type": "code",
"execution_count": 1
04
,
"execution_count": 1
6
,
"id": "004e8ba8",
"metadata": {},
"outputs": [
...
...
@@ -542,7 +541,7 @@
"0.4232928466796875"
]
},
"execution_count": 1
04
,
"execution_count": 1
6
,
"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": []
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment