Commit 18e8282a authored by Bryce Hepner's avatar Bryce Hepner

more tests

parent 669a9a33
......@@ -15,13 +15,14 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"262\n",
"262\n",
"0.3968581030135283\n"
]
......@@ -37,23 +38,25 @@
"list_dic = np.load(\"first_dic.npy\", allow_pickle=\"TRUE\")\n",
"bins = [21,32,48]\n",
"for i in range(len(images)):\n",
"\n",
" \n",
" if images[i][-5:] == \".tiff\":\n",
" newname = images[i][:-5]\n",
" else:\n",
" newname = images[i][:-4]\n",
" if images[i][-18:] != \"Compressedlzw.tiff\":\n",
" newnamesforlater.append(newname + \"_Compressed.txt\")\n",
" # with open(newname + \"_Compressed.txt\", 'wb') as f:\n",
" # f.write(inletters)\n",
" file_sizes_new.append((os.path.getsize(newname + \"_Compressed.txt\")))\n",
" file_sizes_old.append((os.path.getsize(images[i])))\n",
"file_sizes_new.append(os.path.getsize(\"first_dic.npy\"))\n",
"print(len(newnamesforlater))\n",
"print(np.sum(file_sizes_new)/np.sum(file_sizes_old))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 16,
"metadata": {},
"outputs": [
{
......@@ -115,7 +118,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
......@@ -130,19 +133,19 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.34740136372336333\n"
"0.6104417990437042\n"
]
}
],
"source": [
"print((np.sum(pngsizes) - np.sum(file_sizes_new))/np.sum(pngsizes))"
"print((np.sum(pngsizes))/np.sum(file_sizes_old))"
]
},
{
......@@ -154,7 +157,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
......@@ -164,7 +167,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 20,
"metadata": {},
"outputs": [
{
......@@ -185,6 +188,82 @@
"print(np.sum(lwz_sizes)/np.sum(file_sizes_old))"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"524\n",
"262\n"
]
}
],
"source": [
"print(len(images))\n",
"for i, item in enumerate(images):\n",
" # print(item[-18:])\n",
" if item[-18:] == \"Compressedlzw.tiff\":\n",
" os.remove(item)\n",
"scenes = file_extractor(folder_name)\n",
"images = image_extractor(scenes)\n",
"print(len(images))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"def all_image_extractor(scenes):\n",
" \"\"\"\n",
" This function gives the list of all of the valid images\n",
" Parameters:\n",
" scenes (list): a list of all the files in the directory\n",
" Returns:\n",
" images (list): a list of all the images in the directory\n",
" \"\"\"\n",
" image_folder = []\n",
" for scene in scenes:\n",
" files = os.listdir(scene)\n",
" for file in files:\n",
" if file[-7:] == \"_6.tiff\":\n",
" continue\n",
" else:\n",
" image_folder.append(os.path.join(scene, file))\n",
" return image_folder #returns a list of file paths to .tiff files in the specified directory given in file_extractor"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1178\n",
"1178\n"
]
}
],
"source": [
"all_files = all_image_extractor(scenes)\n",
"print(len(all_files))\n",
"for i, item in enumerate(all_files):\n",
" # print(item[-18:])\n",
" if item[-4:] == \"..png\":\n",
" os.remove(item)\n",
"scenes = file_extractor(folder_name)\n",
"all_files = all_image_extractor(scenes)\n",
"print(len(all_files))"
]
},
{
"cell_type": "code",
"execution_count": null,
......
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