Commit 5476cdb4 authored by Bryce Hepner's avatar Bryce Hepner

working on getting the other images over

parent adf762c2
...@@ -16,4 +16,5 @@ attic ...@@ -16,4 +16,5 @@ attic
*.jpeg *.jpeg
*.corr-xml *.corr-xml
*.DS_Store *.DS_Store
lwir16.tar.gz lwir16.tar.gz
\ No newline at end of file *.mp4
\ No newline at end of file
...@@ -93,7 +93,7 @@ if __name__ == "__main__": ...@@ -93,7 +93,7 @@ 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[3][:-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)
...@@ -107,12 +107,12 @@ if __name__ == "__main__": ...@@ -107,12 +107,12 @@ if __name__ == "__main__":
encoded_string2 = bytes_to_bitstring(read_from_file(images[0][:-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)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -15,21 +15,21 @@ ...@@ -15,21 +15,21 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"264\n", "3\n",
"263\n", "3\n",
"0.40415934529931374\n" "0.5416965429002373\n"
] ]
} }
], ],
"source": [ "source": [
"scenes = file_extractor(folder_name)\n", "scenes = file_extractor(\"averaged_images(11)\")\n",
"images = image_extractor(scenes)\n", "images = image_extractor(scenes)\n",
"print(len(images))\n", "print(len(images))\n",
"newnamesforlater = []\n", "newnamesforlater = []\n",
...@@ -48,7 +48,8 @@ ...@@ -48,7 +48,8 @@
" # with open(newname + \"_Compressed.txt\", 'wb') as f:\n", " # with open(newname + \"_Compressed.txt\", 'wb') as f:\n",
" # f.write(inletters)\n", " # f.write(inletters)\n",
" file_sizes_new.append((os.path.getsize(newname + \"_Compressed.txt\")))\n", " file_sizes_new.append((os.path.getsize(newname + \"_Compressed.txt\")))\n",
" file_sizes_old.append((os.path.getsize(newname + \"RemovedFirstLine\" + \".tif\")))\n", " # file_sizes_old.append((os.path.getsize(newname + \"RemovedFirstLine\" + \".tif\")))\n",
" file_sizes_old.append((os.path.getsize(newname + \".tiff\")))\n",
"file_sizes_new.append(os.path.getsize(\"first_dic.npy\"))\n", "file_sizes_new.append(os.path.getsize(\"first_dic.npy\"))\n",
"print(len(newnamesforlater))\n", "print(len(newnamesforlater))\n",
"print(np.sum(file_sizes_new)/np.sum(file_sizes_old))\n" "print(np.sum(file_sizes_new)/np.sum(file_sizes_old))\n"
...@@ -101,22 +102,14 @@ ...@@ -101,22 +102,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"ename": "error", "name": "stdout",
"evalue": "required argument is not an integer", "output_type": "stream",
"output_type": "error", "text": [
"traceback": [ "0.6922330946285837\n"
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31merror\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/home/bryce/git/master/FullTester.ipynb Cell 5'\u001b[0m in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/bryce/git/master/FullTester.ipynb#ch0000004?line=5'>6</a>\u001b[0m \u001b[39mwith\u001b[39;00m \u001b[39mopen\u001b[39m(newnamesforlater[i][:\u001b[39m-\u001b[39m\u001b[39m4\u001b[39m] \u001b[39m+\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m.png\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mwb\u001b[39m\u001b[39m'\u001b[39m) \u001b[39mas\u001b[39;00m f:\n\u001b[1;32m <a href='vscode-notebook-cell:/home/bryce/git/master/FullTester.ipynb#ch0000004?line=6'>7</a>\u001b[0m writer \u001b[39m=\u001b[39m png\u001b[39m.\u001b[39mWriter(newimage\u001b[39m.\u001b[39mshape[\u001b[39m1\u001b[39m], newimage\u001b[39m.\u001b[39mshape[\u001b[39m0\u001b[39m], greyscale\u001b[39m=\u001b[39m\u001b[39mTrue\u001b[39;00m, bitdepth\u001b[39m=\u001b[39m\u001b[39m16\u001b[39m)\n\u001b[0;32m----> <a href='vscode-notebook-cell:/home/bryce/git/master/FullTester.ipynb#ch0000004?line=7'>8</a>\u001b[0m writer\u001b[39m.\u001b[39;49mwrite(f, newimage)\n\u001b[1;32m <a href='vscode-notebook-cell:/home/bryce/git/master/FullTester.ipynb#ch0000004?line=8'>9</a>\u001b[0m pngsizes\u001b[39m.\u001b[39mappend(os\u001b[39m.\u001b[39mpath\u001b[39m.\u001b[39mgetsize(newnamesforlater[i][:\u001b[39m-\u001b[39m\u001b[39m4\u001b[39m] \u001b[39m+\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m.png\u001b[39m\u001b[39m\"\u001b[39m))\n\u001b[1;32m <a href='vscode-notebook-cell:/home/bryce/git/master/FullTester.ipynb#ch0000004?line=9'>10</a>\u001b[0m \u001b[39mprint\u001b[39m(np\u001b[39m.\u001b[39msum(pngsizes)\u001b[39m/\u001b[39mnp\u001b[39m.\u001b[39msum(file_sizes_old))\n",
"File \u001b[0;32m~/.local/lib/python3.8/site-packages/png.py:668\u001b[0m, in \u001b[0;36mWriter.write\u001b[0;34m(self, outfile, rows)\u001b[0m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=664'>665</a>\u001b[0m a \u001b[39m=\u001b[39m array(fmt, itertools\u001b[39m.\u001b[39mchain(\u001b[39m*\u001b[39mcheck_rows(rows)))\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=665'>666</a>\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mwrite_array(outfile, a)\n\u001b[0;32m--> <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=667'>668</a>\u001b[0m nrows \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mwrite_passes(outfile, check_rows(rows))\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=668'>669</a>\u001b[0m \u001b[39mif\u001b[39;00m nrows \u001b[39m!=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mheight:\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=669'>670</a>\u001b[0m \u001b[39mraise\u001b[39;00m ProtocolError(\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=670'>671</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mrows supplied (\u001b[39m\u001b[39m%d\u001b[39;00m\u001b[39m) does not match height (\u001b[39m\u001b[39m%d\u001b[39;00m\u001b[39m)\u001b[39m\u001b[39m\"\u001b[39m \u001b[39m%\u001b[39m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=671'>672</a>\u001b[0m (nrows, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mheight))\n",
"File \u001b[0;32m~/.local/lib/python3.8/site-packages/png.py:703\u001b[0m, in \u001b[0;36mWriter.write_passes\u001b[0;34m(self, outfile, rows)\u001b[0m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=699'>700</a>\u001b[0m \u001b[39melif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mbitdepth \u001b[39m==\u001b[39m \u001b[39m16\u001b[39m:\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=700'>701</a>\u001b[0m rows \u001b[39m=\u001b[39m unpack_rows(rows)\n\u001b[0;32m--> <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=702'>703</a>\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mwrite_packed(outfile, rows)\n",
"File \u001b[0;32m~/.local/lib/python3.8/site-packages/png.py:738\u001b[0m, in \u001b[0;36mWriter.write_packed\u001b[0;34m(self, outfile, rows)\u001b[0m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=734'>735</a>\u001b[0m \u001b[39m# raise i scope out of the for loop. set to -1, because the for loop\u001b[39;00m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=735'>736</a>\u001b[0m \u001b[39m# sets i to 0 on the first pass\u001b[39;00m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=736'>737</a>\u001b[0m i \u001b[39m=\u001b[39m \u001b[39m-\u001b[39m\u001b[39m1\u001b[39m\n\u001b[0;32m--> <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=737'>738</a>\u001b[0m \u001b[39mfor\u001b[39;00m i, row \u001b[39min\u001b[39;00m \u001b[39menumerate\u001b[39m(rows):\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=738'>739</a>\u001b[0m \u001b[39m# Add \"None\" filter type.\u001b[39;00m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=739'>740</a>\u001b[0m \u001b[39m# Currently, it's essential that this filter type be used\u001b[39;00m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=740'>741</a>\u001b[0m \u001b[39m# for every scanline as\u001b[39;00m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=741'>742</a>\u001b[0m \u001b[39m# we do not mark the first row of a reduced pass image;\u001b[39;00m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=742'>743</a>\u001b[0m \u001b[39m# that means we could accidentally compute\u001b[39;00m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=743'>744</a>\u001b[0m \u001b[39m# the wrong filtered scanline if we used\u001b[39;00m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=744'>745</a>\u001b[0m \u001b[39m# \"up\", \"average\", or \"paeth\" on such a line.\u001b[39;00m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=745'>746</a>\u001b[0m data\u001b[39m.\u001b[39mappend(\u001b[39m0\u001b[39m)\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=746'>747</a>\u001b[0m data\u001b[39m.\u001b[39mextend(row)\n",
"File \u001b[0;32m~/.local/lib/python3.8/site-packages/png.py:1001\u001b[0m, in \u001b[0;36munpack_rows\u001b[0;34m(rows)\u001b[0m\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=998'>999</a>\u001b[0m \u001b[39mfor\u001b[39;00m row \u001b[39min\u001b[39;00m rows:\n\u001b[1;32m <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=999'>1000</a>\u001b[0m fmt \u001b[39m=\u001b[39m \u001b[39m'\u001b[39m\u001b[39m!\u001b[39m\u001b[39m%d\u001b[39;00m\u001b[39mH\u001b[39m\u001b[39m'\u001b[39m \u001b[39m%\u001b[39m \u001b[39mlen\u001b[39m(row)\n\u001b[0;32m-> <a href='file:///home/bryce/.local/lib/python3.8/site-packages/png.py?line=1000'>1001</a>\u001b[0m \u001b[39myield\u001b[39;00m \u001b[39mbytearray\u001b[39m(struct\u001b[39m.\u001b[39;49mpack(fmt, \u001b[39m*\u001b[39;49mrow))\n",
"\u001b[0;31merror\u001b[0m: required argument is not an integer"
] ]
} }
], ],
......
...@@ -100,15 +100,26 @@ def find_only_in_channel(images, channel_name = "10"): ...@@ -100,15 +100,26 @@ 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 # adjusted_image = average_image - new_image
# adjusted_image = new_image + (average_image - gaussian_filter(average_image,sigma=5)) # adjusted_image = gaussian_filter(new_image,sigma=1)
adjusted_image = new_image - (average_image - gaussian_filter(average_image,sigma=1))
# adjusted_image = gaussian_filter(adjusted_image,sigma=20)
# 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 - np.array(Image.fromarray(average_image).convert("L").filter(ImageFilter.GaussianBlur(radius=4))))
# adjusted_image = adjusted_image - np.min(adjusted_image) plt.subplot(121)
# adjusted_image = adjusted_image*(original_image_max-original_image_min)/np.max(adjusted_image) plt.imshow(color_adjust((adjusted_image)),cmap='gray',vmin = 0, vmax=1)
# adjusted_image = adjusted_image + original_image_min plt.subplot(122)
plt.imshow(color_adjust(new_image),cmap='gray',vmin = 0, vmax=1)
plt.show()
adjusted_image = adjusted_image - np.min(adjusted_image)
adjusted_image = adjusted_image*(original_image_max-original_image_min)/np.max(adjusted_image)
adjusted_image = adjusted_image + original_image_min
print(adjusted_image.dtype)
return adjusted_image.astype(np.uint16) return adjusted_image.astype(np.uint16)
def color_adjust(visual_array): def color_adjust(visual_array):
...@@ -121,8 +132,8 @@ def save_new_average(quantity_of_images = 1500, channel = "10", head_dir = "/med ...@@ -121,8 +132,8 @@ def save_new_average(quantity_of_images = 1500, channel = "10", head_dir = "/med
scenes = remote_file_extractor(head_dir) scenes = remote_file_extractor(head_dir)
images = find_only_in_channel(remote_image_extractor(scenes),channel) images = find_only_in_channel(remote_image_extractor(scenes),channel)
if quantity_of_images != "all": if quantity_of_images != "all":
# images = np.random.choice(images,quantity_of_images,replace = False) images = np.random.choice(images,quantity_of_images,replace = False)
images = images[:quantity_of_images] # images = images[:quantity_of_images]
average_image = remote_create_average(images,channel) average_image = remote_create_average(images,channel)
# average_image = average_image.astype(int) # average_image = average_image.astype(int)
average_savable_image = Image.fromarray(average_image) average_savable_image = Image.fromarray(average_image)
...@@ -132,25 +143,25 @@ def create_testable_images(images, selected_channel, quantity_of_images): ...@@ -132,25 +143,25 @@ def create_testable_images(images, selected_channel, quantity_of_images):
sftp_client = setup_remote_sftpclient() sftp_client = setup_remote_sftpclient()
images = find_only_in_channel(images, selected_channel) images = find_only_in_channel(images, selected_channel)
image_locations = np.random.choice(len(images), quantity_of_images, replace=False) # image_locations = np.random.choice(len(images), quantity_of_images, replace=False)
# image_locations = np.arange(quantity_of_images) + 10000 image_locations = np.arange(quantity_of_images) + 10000
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 = 40 images_in_each_direction = 80
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)
elif image_locations[i] > (len(images) - images_in_each_direction): # elif image_locations[i] > (len(images) - images_in_each_direction):
average_image = remote_create_average(images[image_locations[i] - images_in_each_direction - (len(images) - image_locations[i]): image_locations[i] + (len(images) - image_locations[i])], selected_channel) # average_image = remote_create_average(images[image_locations[i] - images_in_each_direction - (len(images) - image_locations[i]): image_locations[i] + (len(images) - image_locations[i])], selected_channel)
else: # else:
average_image = remote_create_average(images[image_locations[i] - images_in_each_direction: image_locations[i] + images_in_each_direction], selected_channel) # average_image = remote_create_average(images[image_locations[i] - images_in_each_direction: image_locations[i] + images_in_each_direction], selected_channel)
image = Image.open(sftp_client.open(item)) image = Image.open(sftp_client.open(item))
wherelastslash = item.rfind("/") wherelastslash = item.rfind("/")
image = np.array(image)[1:] image = np.array(image)[1:]
savable_original = Image.fromarray(image) savable_original = Image.fromarray(image)
savable_original.save("averaged_images(" + selected_channel + ")/innerfolder/original" + item[wherelastslash + 1:]) # savable_original.save("averaged_images(" + selected_channel + ")/innerfolder/original" + item[wherelastslash + 1:])
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)
...@@ -160,19 +171,19 @@ def create_testable_images(images, selected_channel, quantity_of_images): ...@@ -160,19 +171,19 @@ def create_testable_images(images, selected_channel, quantity_of_images):
sftp_client.close() sftp_client.close()
if __name__ == "__main__": if __name__ == "__main__":
# save_new_average(15,"11") # save_new_average(350,"11")
scenes = remote_file_extractor("/media/elphel/NVME/lwir16-proc/te0607/scenes/") scenes = remote_file_extractor("/media/elphel/NVME/lwir16-proc/te0607/scenes/")
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",2) create_testable_images(images,"11",3)
# 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()
# print(len(images)) # print(len(images))
average_image = remote_create_average(images[10000 - 10: 10000 + 10], "11") average_image = remote_create_average(images[10000 - 10: 10000 + 10], "11")
plt.imshow(color_adjust((average_image - gaussian_filter(average_image,sigma=5))),cmap='gray',vmin = 0, vmax=1) # plt.imshow(color_adjust((average_image - gaussian_filter(average_image,sigma=5))),cmap='gray',vmin = 0, vmax=1)
plt.show() # plt.show()
sftp_client = setup_remote_sftpclient() sftp_client = setup_remote_sftpclient()
print(len(images)) print(len(images))
# print(images[10000]) # print(images[10000])
...@@ -185,11 +196,15 @@ if __name__ == "__main__": ...@@ -185,11 +196,15 @@ if __name__ == "__main__":
# newimage = Image.fromarray(test_image - average_image) # newimage = Image.fromarray(test_image - average_image)
# newimage.save("NoInterference.tiff") # newimage.save("NoInterference.tiff")
plt.subplot(121) # plt.subplot(121)
plt.imshow(color_adjust(test_image),cmap='gray',vmin = 0, vmax=1) # plt.imshow(color_adjust(test_image),cmap='gray',vmin = 0, vmax=1)
plt.subplot(122) # plt.subplot(122)
plt.imshow(color_adjust(adjust_to_original(test_image,average_image)),cmap='gray',vmin = 0, vmax=1) # plt.imshow(color_adjust(adjust_to_original(test_image,average_image)),cmap='gray',vmin = 0, vmax=1)
plt.show() # plt.show()
sftp_client.close() sftp_client.close()
# print(np.linalg.inv(np.array([[3,0,-1],[0,3,3],[1,-3,-4]]))) # print(np.linalg.inv(np.array([[3,0,-1],[0,3,3],[1,-3,-4]])))
# print(np.linalg.pinv(np.array([[-1,-1,1], [-1,0,1], [-1,1,1], [0,-1,1]]))) # print(np.linalg.pinv(np.array([[-1,-1,1], [-1,0,1], [-1,1,1], [0,-1,1]])))
\ No newline at end of file
last_image = Image.open("NoInterference.tiff")
# plt.imshow(color_adjust(np.array(last_image)),cmap='gray',vmin = 0, vmax=1)
# plt.show()
\ No newline at end of file
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"ename": "SystemError",
"evalue": "<built-in function imwrite> returned NULL without setting an error",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mSystemError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/home/bryce/git/master/VideoToImage.ipynb Cell 1'\u001b[0m in \u001b[0;36m<cell line: 5>\u001b[0;34m()\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/bryce/git/master/VideoToImage.ipynb#ch0000000?line=3'>4</a>\u001b[0m count \u001b[39m=\u001b[39m \u001b[39m0\u001b[39m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/bryce/git/master/VideoToImage.ipynb#ch0000000?line=4'>5</a>\u001b[0m \u001b[39mwhile\u001b[39;00m success \u001b[39mand\u001b[39;00m count \u001b[39m<\u001b[39m \u001b[39m5\u001b[39m:\n\u001b[0;32m----> <a href='vscode-notebook-cell:/home/bryce/git/master/VideoToImage.ipynb#ch0000000?line=5'>6</a>\u001b[0m cv2\u001b[39m.\u001b[39;49mimwrite(\u001b[39m\"\u001b[39;49m\u001b[39mbetterimages/innerfolder/fram\u001b[39;49m\u001b[39m%d\u001b[39;49;00m\u001b[39m.jpg\u001b[39;49m\u001b[39m\"\u001b[39;49m \u001b[39m%\u001b[39;49m count, image, \u001b[39m0\u001b[39;49m)\n\u001b[1;32m <a href='vscode-notebook-cell:/home/bryce/git/master/VideoToImage.ipynb#ch0000000?line=6'>7</a>\u001b[0m success, image \u001b[39m=\u001b[39m vidcap\u001b[39m.\u001b[39mread()\n\u001b[1;32m <a href='vscode-notebook-cell:/home/bryce/git/master/VideoToImage.ipynb#ch0000000?line=7'>8</a>\u001b[0m count \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m1\u001b[39m\n",
"\u001b[0;31mSystemError\u001b[0m: <built-in function imwrite> returned NULL without setting an error"
]
}
],
"source": [
"import cv2\n",
"vidcap = cv2.VideoCapture(\"concat_mono-fg_realtime.mp4\")\n",
"success,image = vidcap.read()\n",
"count = 0\n",
"while success and count < 5:\n",
" cv2.imwrite(\"betterimages/innerfolder/fram%d.jpg\" % count, image, 0)\n",
" success, image = vidcap.read()\n",
" count += 1"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(512, 640, 3)\n",
"(512, 640, 3)\n",
"(512, 640, 3)\n",
"(512, 640, 3)\n",
"(512, 640, 3)\n"
]
}
],
"source": [
"from PIL import Image\n",
"import numpy as np\n",
"for i in range(5):\n",
" im = Image.open(\"betterimages/innerfolder/fram\" + str(i) + \".jpg\", )\n",
" print(np.array(im).shape)\n",
" im.save(\"betterimages/innerfolder/fram\" + str(i) + \".tiff\", 'TIFF')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.10 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
...@@ -514,7 +514,7 @@ def text_to_tiff(filename, list_dic, bins): ...@@ -514,7 +514,7 @@ def text_to_tiff(filename, list_dic, bins):
if __name__ == "__main__": if __name__ == "__main__":
scenes = file_extractor("averaged_images(11)") scenes = file_extractor("betterimages")
images = image_extractor(scenes) images = image_extractor(scenes)
newnamesforlater = [] newnamesforlater = []
list_dic, bins = make_dictionary(images, 4, False) list_dic, bins = make_dictionary(images, 4, False)
...@@ -543,6 +543,8 @@ if __name__ == "__main__": ...@@ -543,6 +543,8 @@ if __name__ == "__main__":
# if i % 50 == 0: # if i % 50 == 0:
# print(i) # print(i)
# sleep(20) # sleep(20)
print(file_sizes_new)
print(file_sizes_old)
print(np.sum(file_sizes_new)/np.sum(file_sizes_old)) print(np.sum(file_sizes_new)/np.sum(file_sizes_old))
file_sizes_new.append(os.path.getsize("first_dic.npy")) file_sizes_new.append(os.path.getsize("first_dic.npy"))
print(np.sum(file_sizes_new)/np.sum(file_sizes_old)) print(np.sum(file_sizes_new)/np.sum(file_sizes_old))
......
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