Commit 9d5cbb08 authored by Bryce Hepner's avatar Bryce Hepner
Browse files

changed while making graphs

parent e8a6c815
Loading
Loading
Loading
Loading
+229 −65

File changed.

Preview size limit exceeded, changes collapsed.

+16 −16
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ def make_dictionary(tiff_image_path_list, num_bins=4, difference = True):
        # plt.title('Histogram of Pixel Values')
        # plt.show()
        
        bins = [29,44,67]
        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]))
        
@@ -290,7 +290,7 @@ def huffman(tiff_image_path, num_bins=4, difference = True):
    # get the image_as_array, etc
    image_as_array, diff, error= predict_pix(tiff_image_path, difference)
    
    bins = [29,44,67]
    bins = [21,32,48]
    # get the boundary 
    boundary = np.hstack((image_as_array[0,:],image_as_array[-1,:],image_as_array[1:-1,0],image_as_array[1:-1,-1]))
    
@@ -548,16 +548,16 @@ if __name__ == "__main__":
    scenes = file_extractor("images")
    images = image_extractor(scenes)
    newnamesforlater = []
    list_dic, bins = make_dictionary(images, 4, True)
    list_dic, bins = make_dictionary(images, 4, False)
    file_sizes_new = []
    file_sizes_old = []
    # list_dic = np.load("first_dict.npy", allow_pickle="True")
    bins = [29,44,67]
    bins = [21,32,48]
    #otherbins = [21,32,48]
    np.save("first_dict.npy", list_dic)
    for i in np.random.choice(len(images), 10):
    for i in range(3):

        image, new_error, diff = huffman(images[i], 4, True)
        image, new_error, diff = huffman(images[i], 4, False)
        encoded_string = encoder(new_error, list_dic, diff, bins)
        inletters = bitstring_to_bytes(encoded_string)

@@ -578,15 +578,15 @@ if __name__ == "__main__":
    file_sizes_new.append(os.path.getsize("first_dict.npy"))
    print(np.sum(file_sizes_new)/np.sum(file_sizes_old))
    # list_dic = np.load("first_dict.npy", allow_pickle="TRUE")
    bins = [29,44,67]
    bins = [21,32,48]

    # for i,item in enumerate(newnamesforlater):
    for i,item in enumerate(newnamesforlater):
        # print(item)
    #     image, new_error, diff = huffman(images[i], 4, False)
    #     encoded_string2 = bytes_to_bitstring(read_from_file(item))
    #     starttime = time()
    #     reconstruct_image = decoder(encoded_string2, list_dic, bins, False)
    #     print(np.allclose(image, reconstruct_image))
        image, new_error, diff = huffman(images[i], 4, False)
        encoded_string2 = bytes_to_bitstring(read_from_file(item))
        starttime = time()
        reconstruct_image = decoder(encoded_string2, list_dic, bins, False)
        print(np.allclose(image, reconstruct_image))
        # print(time() - starttime)
    # text_to_tiff("images/1626033496_437803/1626033496_437803_3._Compressed.txt", list_dic, bins)
    # original_image = Image.open("images/1626033496_437803/1626033496_437803_3.tiff")