Commit 76fd64f3 authored by Bryce Hepner's avatar Bryce Hepner

Just testbench changes

parent e6bd581c
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
......@@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
......@@ -72,7 +72,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
......@@ -147,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 119,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
......@@ -198,18 +198,17 @@
" #There is a huge memory leak here, no idea how or why\n",
" nodes = sorted(nodes, key=lambda x: x[1], reverse=True)\n",
" return nodes[0][0]\n",
"def decode_string(huffman_string, the_values, the_keys):\n",
"def decode_string(huffman_string, the_keys, the_values):\n",
" for i in range(len(huffman_string)):\n",
" try:\n",
" return (int(the_keys[the_values.index(huffman_string[:i+1])]),huffman_string[i+1:])\n",
" except:\n",
" pass\n",
" "
" pass\n"
]
},
{
"cell_type": "code",
"execution_count": 120,
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
......@@ -261,6 +260,7 @@
" \n",
" # create a list of huffman table\n",
" huffman_encoding_list = [huffman_encoding_dict]\n",
" print(len(huffman_encoding_list))\n",
" n = len(bins)\n",
" \n",
" # loop through different bins\n",
......@@ -311,13 +311,14 @@
" # huffman_encoding_list = list(set(huffman_encoding_list))\n",
" diff = np.reshape(diff,(510,638))\n",
" # return the huffman dictionary\n",
" print(len(huffman_encoding_list))\n",
" return huffman_encoding_list, image_array, new_error, diff, boundary, predict, bins, A\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 121,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
......@@ -334,7 +335,7 @@
" Return:\n",
" encoded (512, 640): encoded matrix\n",
" \"\"\"\n",
" returnableencode = \"\"\n",
" returnable_encode = \"\"\n",
" # copy the error matrix (including the boundary)\n",
" encoded = np.copy(error).astype(int).astype(str).astype(object)\n",
" #diff = np.reshape(diff,(510,638))\n",
......@@ -342,22 +343,22 @@
" for i in range(encoded.shape[0]):\n",
" for j in range(encoded.shape[1]):\n",
" if i == 0 or i == encoded.shape[0]-1 or j == 0 or j == encoded.shape[1]-1:\n",
" returnableencode += list_dic[0][encoded[i][j]]\n",
" returnable_encode += list_dic[0][encoded[i][j]]\n",
" elif diff[i-1][j-1] <= bins[0]:\n",
" returnableencode += list_dic[1][encoded[i][j]]\n",
" returnable_encode += list_dic[1][encoded[i][j]]\n",
" elif diff[i-1][j-1] <= bins[1] and diff[i-1][j-1] > bins[0]:\n",
" returnableencode +=list_dic[2][encoded[i][j]]\n",
" returnable_encode +=list_dic[2][encoded[i][j]]\n",
" elif diff[i-1][j-1] <= bins[2] and diff[i-1][j-1] > bins[1]:\n",
" returnableencode +=list_dic[3][encoded[i][j]]\n",
" returnable_encode +=list_dic[3][encoded[i][j]]\n",
" else:\n",
" returnableencode += list_dic[4][encoded[i][j]]\n",
" returnable_encode += list_dic[4][encoded[i][j]]\n",
"\n",
" return returnableencode"
" return returnable_encode"
]
},
{
"cell_type": "code",
"execution_count": 133,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
......@@ -374,7 +375,7 @@
" decode_matrix (512, 640): decoded matrix\n",
" \"\"\"\n",
" # change the dictionary back to list\n",
" # !!!!!WARNING!!!! has to change this part, eveytime you change the number of bins\n",
" # !!!!!WARNING!!!! has to change this part, everytime you change the number of bins\n",
" the_keys0 = list(list_dic[0].keys())\n",
" the_values0 = list(list_dic[0].values())\n",
" \n",
......@@ -440,14 +441,13 @@
" else:\n",
" colorvalue, encoded_string = decode_string(encoded_string,the_keys=the_keys4, the_values=the_values4)\n",
" decode_matrix[i][j] = colorvalue + int(predict)\n",
" \n",
" \n",
"\n",
" return decode_matrix.astype(int)"
]
},
{
"cell_type": "code",
"execution_count": 134,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
......@@ -510,14 +510,14 @@
},
{
"cell_type": "code",
"execution_count": 136,
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n",
"1\n",
"5\n"
]
}
......@@ -534,7 +534,7 @@
},
{
"cell_type": "code",
"execution_count": 131,
"execution_count": 26,
"metadata": {},
"outputs": [
{
......@@ -543,7 +543,7 @@
"0.4232928466796875"
]
},
"execution_count": 131,
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
......@@ -554,7 +554,7 @@
},
{
"cell_type": "code",
"execution_count": 149,
"execution_count": 11,
"metadata": {},
"outputs": [
{
......@@ -573,7 +573,7 @@
},
{
"cell_type": "code",
"execution_count": 140,
"execution_count": 12,
"metadata": {},
"outputs": [
{
......@@ -590,14 +590,14 @@
},
{
"cell_type": "code",
"execution_count": 169,
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"398145\n"
"2080569\n"
]
}
],
......@@ -607,7 +607,7 @@
},
{
"cell_type": "code",
"execution_count": 167,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
......@@ -633,7 +633,7 @@
},
{
"cell_type": "code",
"execution_count": 168,
"execution_count": 15,
"metadata": {},
"outputs": [
{
......@@ -670,6 +670,13 @@
"(os.path.getsize('MatrixNowString.txt'))/os.path.getsize('images/1626032610_393963/1626032610_393963_0.tiff')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"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