Commit 0f1af9da authored by Bryce Hepner's avatar Bryce Hepner

time stamp triggered change

parent 51ac3d5f
......@@ -212,18 +212,18 @@
},
{
"cell_type": "code",
"execution_count": 59,
"execution_count": 64,
"metadata": {},
"outputs": [],
"source": [
"from PIL import TiffTags\n",
"TiffTags.LIBTIFF_CORE.add(317)\n",
"picture.save('round_2.tiff', compression='tiff_lzw', tiffinfo={317: 2})"
"picture.save('Compressed_Round_2.tiff', compression='tiff_lzw', tiffinfo={317: 2})"
]
},
{
"cell_type": "code",
"execution_count": 60,
"execution_count": 65,
"metadata": {},
"outputs": [
{
......@@ -235,12 +235,12 @@
}
],
"source": [
"print(os.path.getsize('round_2.tiff'))"
"print(os.path.getsize('Compressed_Round_2.tiff'))"
]
},
{
"cell_type": "code",
"execution_count": 61,
"execution_count": 66,
"metadata": {},
"outputs": [
{
......@@ -266,12 +266,186 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Round 2: Trying the same thing but with tifffile and doing grayscale"
"Round 2: Trying the same thing but with tifffile and doing grayscale\n",
"Conclusion: The documentation was terrible. It advertizes compression but doesn't say how it's done, and the specifics of it. Moving on to something else, but still worth a shot."
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<PIL.TiffImagePlugin.TiffImageFile image mode=I;16B size=640x513 at 0x7F3520192160>\n"
]
}
],
"source": [
"scenes = file_extractor()\n",
"images = image_extractor(scenes)\n",
"first_source = images[0]\n",
"picture = Image.open(first_source)\n",
"print(picture.size)"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [],
"source": [
"import tifffile"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 2 1 54668 ... 65535 65535 65535]\n",
" [22275 22292 22292 ... 22280 22212 22270]\n",
" [22303 22301 22298 ... 22254 22248 22262]\n",
" ...\n",
" [21832 21820 21844 ... 21892 21852 21845]\n",
" [21843 21821 21830 ... 21870 21865 21864]\n",
" [21836 21829 21840 ... 21858 21857 21860]]\n"
]
}
],
"source": [
"otherpic = tifffile.imread(first_source)\n",
"print(otherpic)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Round 3: Trying numcompress, something that compresses numbers. Should provide an ok benchmark, and is actually documented."
]
},
{
"cell_type": "code",
"execution_count": 98,
"metadata": {},
"outputs": [],
"source": [
"from numcompress import compress_ndarray, decompress_ndarray"
]
},
{
"cell_type": "code",
"execution_count": 113,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n",
"452529\n",
"328320\n"
]
}
],
"source": [
"# print(list(otherpic).dtype)\n",
"otherpic = tifffile.imread(first_source)\n",
"\n",
"compressed = compress_ndarray(otherpic, precision = 0)\n",
"# print(compressed)\n",
"decompressed = decompress_ndarray(compressed)\n",
"print(np.allclose(otherpic,decompressed))\n",
"print(len(compressed))\n",
"print(otherpic.size)"
]
},
{
"cell_type": "code",
"execution_count": 109,
"metadata": {},
"outputs": [],
"source": [
"with open(\"ThirdTry.txt\", 'w') as f:\n",
" f.write(compressed)"
]
},
{
"cell_type": "code",
"execution_count": 111,
"metadata": {},
"outputs": [],
"source": [
"thirdsize = os.path.getsize(\"ThirdTry.txt\")"
]
},
{
"cell_type": "code",
"execution_count": 114,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.31142564558267916\n"
]
}
],
"source": [
"print((oldsize-thirdsize)/oldsize)"
]
},
{
"cell_type": "code",
"execution_count": 115,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"452578"
]
},
"execution_count": 115,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sys.getsizeof(compressed)"
]
},
{
"cell_type": "code",
"execution_count": 116,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"112"
]
},
"execution_count": 116,
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"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