Project 'Elphel/master' was moved to 'Elphel/image-compression'. Please update any links and bookmarks that may still have the old path.
Commit c34f9bd7 authored by Bryce Hepner's avatar Bryce Hepner

modified code so now it calculates total

parent 45e246f4
......@@ -191,7 +191,11 @@ def make_dictionary(tiff_image_path_list, num_bins=4, difference = True):
for _, tiff_image_path in enumerate(tiff_image_path_list):
# get the image_array, etc
image_array, diff, error= predict_pix(tiff_image_path, difference)
# plt.hist(np.ravel(image_array), bins=30)
# plt.xlabel('Pixel Value')
# plt.ylabel('Frequency')
# plt.title('Histogram of Pixel Values')
# plt.show()
bins = [21,32,48]
# get the boundary
boundary = np.hstack((image_array[0,:],image_array[-1,:],image_array[1:-1,0],image_array[1:-1,-1]))
......@@ -234,6 +238,11 @@ def make_dictionary(tiff_image_path_list, num_bins=4, difference = True):
mask = diff > bins[-1]
for j in error[mask].astype(int):
list_of_all_vals[-1].append(str(j))
# plt.hist([int(i) for i in list_of_all_vals[2]], bins=30)
# plt.xlabel("Error")
# plt.ylabel("Frequency")
# plt.title("Histogram of Errors")
# plt.show()
for item in list_of_all_vals:
freq = dict(Counter(item))
freq = sorted(freq.items(), key=lambda x: x[1], reverse=True)
......@@ -490,10 +499,11 @@ def bytes_to_bitstring(input_bytearray):
scenes = file_extractor(folder_name)
newnamesforlater = []
images = image_extractor(scenes)
# list_dic, bins = make_dictionary(images, 4, False)
file_size_ratios = []
list_dic, bins = make_dictionary(images, 4, False)
file_sizes_new = []
file_sizes_old = []
# np.save("first_dic.npy", list_dic)
for i in range(len(images)):
for i in range(1):
# image, new_error, diff = huffman(images[i], 4, False)
# encoded_string = encoder(new_error, list_dic, diff, bins)
# inletters = bitstring_to_bytes(encoded_string)
......@@ -504,7 +514,10 @@ for i in range(len(images)):
newnamesforlater.append(newname + "_Compressed.txt")
# with open(newname + "_Compressed.txt", 'wb') as f:
# f.write(inletters)
file_size_ratios.append((os.path.getsize(newname + "_Compressed.txt"))/os.path.getsize(images[i]))
file_sizes_new.append((os.path.getsize(newname + "_Compressed.txt")))
file_sizes_old.append((os.path.getsize(images[i])))
file_sizes_new.append(os.path.getsize("first_dic.npy"))
# print(np.sum(file_sizes_new)/np.sum(file_sizes_old))
# list_dic = np.load("first_dic.npy", allow_pickle="TRUE")
# for i,item in enumerate(newnamesforlater[0:10]):
......
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