Commit a9bf04b8 authored by Bryce Hepner's avatar Bryce Hepner

Modified in running, tests successful

parent 9c9419fe
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 2,
"id": "14f74f21", "id": "14f74f21",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 3,
"id": "c16af61f", "id": "c16af61f",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 4,
"id": "53786325", "id": "53786325",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 5,
"id": "6b965751", "id": "6b965751",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 6,
"id": "b7561883", "id": "b7561883",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
...@@ -318,7 +318,7 @@ ...@@ -318,7 +318,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 7,
"id": "2eb774d2", "id": "2eb774d2",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
...@@ -358,7 +358,7 @@ ...@@ -358,7 +358,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 8,
"id": "8eeb40d0", "id": "8eeb40d0",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
...@@ -402,6 +402,9 @@ ...@@ -402,6 +402,9 @@
" # if it's the very first pixel on the image\n", " # if it's the very first pixel on the image\n",
" if i == 0 and j == 0:\n", " if i == 0 and j == 0:\n",
" decode_matrix[i][j] = int(the_keys0[the_values0.index(encoded_matrix[i,j])])\n", " decode_matrix[i][j] = int(the_keys0[the_values0.index(encoded_matrix[i,j])])\n",
" print(encoded_matrix[i][j])\n",
" print(the_values0.index(encoded_matrix[i,j]))\n",
" print(int(the_keys0[the_values0.index(encoded_matrix[i,j])]))\n",
" # if it's on the boundary (any of the 4 edges)\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", " 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", " decode_matrix[i][j] = int(the_keys0[the_values0.index(encoded_matrix[i,j])]) + decode_matrix[0][0]\n",
...@@ -442,7 +445,7 @@ ...@@ -442,7 +445,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 9,
"id": "f959fe93", "id": "f959fe93",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
...@@ -506,7 +509,7 @@ ...@@ -506,7 +509,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 10,
"id": "3e0e9742", "id": "3e0e9742",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
...@@ -514,6 +517,9 @@ ...@@ -514,6 +517,9 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"11100100000\n",
"499\n",
"22275\n",
"True\n", "True\n",
"5\n" "5\n"
] ]
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 46, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 47, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 48, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 49, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 50, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 51, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 52, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 53, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 54, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 55, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 56, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 57, "execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 58, "execution_count": 14,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -213,35 +213,46 @@ ...@@ -213,35 +213,46 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 64, "execution_count": 15,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from PIL import TiffTags\n", "from PIL import TiffTags\n",
"TiffTags.LIBTIFF_CORE.add(317)\n", "TiffTags.LIBTIFF_CORE.add(318)\n",
"picture.save('Compressed_Round_2.tiff', compression='tiff_lzw', tiffinfo={317: 2})" "picture.save('Compressed_Round_2.tiff', compression='tiff_lzw', tiffinfo={317: 2})"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 65, "execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"404176\n" "404176\n",
"True\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/bryce/.local/lib/python3.8/site-packages/PIL/TiffImagePlugin.py:845: UserWarning: Truncated File Read\n",
" warnings.warn(str(msg))\n"
] ]
} }
], ],
"source": [ "source": [
"print(os.path.getsize('Compressed_Round_2.tiff'))" "print(os.path.getsize('Compressed_Round_2.tiff'))\n",
"potentially_compressed = Image.open('Compressed_Round_2.tiff')\n",
"print(np.allclose(picture,potentially_compressed))"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 66, "execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -274,14 +285,14 @@ ...@@ -274,14 +285,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 71, "execution_count": 17,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"<PIL.TiffImagePlugin.TiffImageFile image mode=I;16B size=640x513 at 0x7F3520192160>\n" "(640, 513)\n"
] ]
} }
], ],
...@@ -295,7 +306,7 @@ ...@@ -295,7 +306,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 68, "execution_count": 18,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -304,7 +315,7 @@ ...@@ -304,7 +315,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 72, "execution_count": 19,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -337,7 +348,7 @@ ...@@ -337,7 +348,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 98, "execution_count": 20,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -346,7 +357,7 @@ ...@@ -346,7 +357,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 113, "execution_count": 21,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -373,7 +384,7 @@ ...@@ -373,7 +384,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 109, "execution_count": 22,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -383,7 +394,7 @@ ...@@ -383,7 +394,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 111, "execution_count": 23,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -392,24 +403,24 @@ ...@@ -392,24 +403,24 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 114, "execution_count": 24,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"0.31142564558267916\n" "0.6885743544173208\n"
] ]
} }
], ],
"source": [ "source": [
"print((oldsize-thirdsize)/oldsize)" "print((thirdsize)/oldsize)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 115, "execution_count": 25,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -418,7 +429,7 @@ ...@@ -418,7 +429,7 @@
"452578" "452578"
] ]
}, },
"execution_count": 115, "execution_count": 25,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -429,20 +440,9 @@ ...@@ -429,20 +440,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 116, "execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"112"
]
},
"execution_count": 116,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "outputs": [],
}
],
"source": [] "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