Commit adf762c2 authored by Bryce Hepner's avatar Bryce Hepner

checkpoint, forgot when I was sick

parent de772659
...@@ -93,26 +93,26 @@ if __name__ == "__main__": ...@@ -93,26 +93,26 @@ if __name__ == "__main__":
list_dic = np.load("second_dic.npy", allow_pickle="TRUE") list_dic = np.load("second_dic.npy", allow_pickle="TRUE")
bins = [21,32,48] bins = [21,32,48]
print(images) print(images)
encoded_string2 = bytes_to_bitstring(read_from_file(images[0][:-5] + "_Compressed.txt")) encoded_string2 = bytes_to_bitstring(read_from_file(images[3][:-5] + "_Compressed.txt"))
original_array, error_array = produce_error_array(encoded_string2, list_dic, bins, False) original_array, error_array = produce_error_array(encoded_string2, list_dic, bins, False)
adjusted_errors = color_adjust(abs(error_array)) adjusted_errors = color_adjust(abs(error_array))
original_array_adjusted = color_adjust(original_array) original_array_adjusted = color_adjust(original_array)
# print(adjusted_errors) # print(adjusted_errors)
print(error_array) print(error_array)
plt.subplot(121) plt.subplot(131)
plt.imshow(original_array_adjusted,cmap='gray',vmin = 0, vmax=255) plt.imshow(original_array_adjusted,cmap='gray',vmin = 0, vmax=255)
plt.subplot(122) plt.subplot(132)
plt.imshow(adjusted_errors,cmap = 'gray', vmin = 0, vmax=255) plt.imshow(adjusted_errors,cmap = 'gray', vmin = 0, vmax=255)
# encoded_string2 = bytes_to_bitstring(read_from_file(images[1][:-5] + "_Compressed.txt")) encoded_string2 = bytes_to_bitstring(read_from_file(images[0][:-5] + "_Compressed.txt"))
# original_array, error_array = produce_error_array(encoded_string2, list_dic, bins, False) original_array, error_array = produce_error_array(encoded_string2, list_dic, bins, False)
# adjusted_errors = color_adjust(abs(error_array)) adjusted_errors = color_adjust(abs(error_array))
# original_array_adjusted = color_adjust(original_array) original_array_adjusted = color_adjust(original_array)
# plt.subplot(133) plt.subplot(133)
# plt.imshow(adjusted_errors,cmap = 'gray', vmin = 0, vmax=255) plt.imshow(adjusted_errors,cmap = 'gray', vmin = 0, vmax=255)
......
...@@ -9,6 +9,7 @@ def setup_remote_sftpclient(): ...@@ -9,6 +9,7 @@ def setup_remote_sftpclient():
client.connect("192.168.0.107", username="elphel") client.connect("192.168.0.107", username="elphel")
sftp_client = client.open_sftp() sftp_client = client.open_sftp()
return sftp_client return sftp_client
def remove_noise(images, which_sensor): def remove_noise(images, which_sensor):
same_sensor_images = [] same_sensor_images = []
which_sensor = str(which_sensor) which_sensor = str(which_sensor)
...@@ -99,14 +100,15 @@ def find_only_in_channel(images, channel_name = "10"): ...@@ -99,14 +100,15 @@ def find_only_in_channel(images, channel_name = "10"):
same_sensor_images.append(image_name) same_sensor_images.append(image_name)
return same_sensor_images return same_sensor_images
def adjust_to_original(new_image, average_image): def adjust_to_original(new_image, average_image):
original_image_min = np.min(new_image) # original_image_min = np.min(new_image)
original_image_max = np.max(new_image) # original_image_max = np.max(new_image)
# average_image = average_image - np.mean(average_image) average_image = average_image - np.mean(average_image)
adjusted_image = new_image - (average_image - gaussian_filter(average_image,sigma=5)) adjusted_image = new_image - average_image
# adjusted_image = new_image - (average_image - np.array(Image.fromarray(average_image).convert("L").filter(ImageFilter.GaussianBlur(radius=4)))) # adjusted_image = new_image + (average_image - gaussian_filter(average_image,sigma=5))
adjusted_image = adjusted_image - np.min(adjusted_image) # adjusted_image = new_image + (average_image - np.array(Image.fromarray(average_image).convert("L").filter(ImageFilter.GaussianBlur(radius=4))))
adjusted_image = adjusted_image*(original_image_max-original_image_min)/np.max(adjusted_image) # adjusted_image = adjusted_image - np.min(adjusted_image)
adjusted_image = adjusted_image + original_image_min # adjusted_image = adjusted_image*(original_image_max-original_image_min)/np.max(adjusted_image)
# adjusted_image = adjusted_image + original_image_min
return adjusted_image.astype(np.uint16) return adjusted_image.astype(np.uint16)
def color_adjust(visual_array): def color_adjust(visual_array):
...@@ -136,7 +138,7 @@ def create_testable_images(images, selected_channel, quantity_of_images): ...@@ -136,7 +138,7 @@ def create_testable_images(images, selected_channel, quantity_of_images):
selected_images = np.array(images)[image_locations] selected_images = np.array(images)[image_locations]
# average_image = np.array(Image.open("Average_On_Channel(" + selected_channel + ").tiff")) # average_image = np.array(Image.open("Average_On_Channel(" + selected_channel + ").tiff"))
images_in_each_direction = 4 images_in_each_direction = 40
for i, item in enumerate(selected_images): for i, item in enumerate(selected_images):
if image_locations[i] < images_in_each_direction: if image_locations[i] < images_in_each_direction:
average_image = remote_create_average(images[image_locations[i] - image_locations[i]: image_locations[i] + images_in_each_direction + image_locations[i]], selected_channel) average_image = remote_create_average(images[image_locations[i] - image_locations[i]: image_locations[i] + images_in_each_direction + image_locations[i]], selected_channel)
...@@ -152,7 +154,7 @@ def create_testable_images(images, selected_channel, quantity_of_images): ...@@ -152,7 +154,7 @@ def create_testable_images(images, selected_channel, quantity_of_images):
altered_image = adjust_to_original(image, average_image) altered_image = adjust_to_original(image, average_image)
altered_image = Image.fromarray(altered_image) altered_image = Image.fromarray(altered_image)
# altered_image.save("averaged_images(" + selected_channel + ")/innerfolder" + item[wherelastslash:]) altered_image.save("averaged_images(" + selected_channel + ")/innerfolder" + item[wherelastslash:])
# average_image = Image.fromarray(average_image) # average_image = Image.fromarray(average_image)
sftp_client.close() sftp_client.close()
...@@ -163,7 +165,7 @@ if __name__ == "__main__": ...@@ -163,7 +165,7 @@ if __name__ == "__main__":
images = remote_image_extractor(scenes) images = remote_image_extractor(scenes)
images = find_only_in_channel(images, "11") images = find_only_in_channel(images, "11")
# average_image = np.array(Image.open("Average_On_Channel(" + "11" + ").tiff")) # average_image = np.array(Image.open("Average_On_Channel(" + "11" + ").tiff"))
create_testable_images(images,"11",10) create_testable_images(images,"11",2)
# plt.imshow(color_adjust(average_image),cmap='gray',vmin = 0, vmax=1) # plt.imshow(color_adjust(average_image),cmap='gray',vmin = 0, vmax=1)
# plt.show() # plt.show()
......
No preview for this file type
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