Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
image-compression
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
image-compression
Commits
adf762c2
Commit
adf762c2
authored
Jul 05, 2022
by
Bryce Hepner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkpoint, forgot when I was sick
parent
de772659
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
20 deletions
+22
-20
ErrorImageCreator.py
ErrorImageCreator.py
+9
-9
Remove_Noise.py
Remove_Noise.py
+13
-11
second_dic.npy
second_dic.npy
+0
-0
No files found.
ErrorImageCreator.py
View file @
adf762c2
...
...
@@ -93,26 +93,26 @@ if __name__ == "__main__":
list_dic
=
np
.
load
(
"second_dic.npy"
,
allow_pickle
=
"TRUE"
)
bins
=
[
21
,
32
,
48
]
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
)
adjusted_errors
=
color_adjust
(
abs
(
error_array
))
original_array_adjusted
=
color_adjust
(
original_array
)
# print(adjusted_errors)
print
(
error_array
)
plt
.
subplot
(
1
2
1
)
plt
.
subplot
(
1
3
1
)
plt
.
imshow
(
original_array_adjusted
,
cmap
=
'gray'
,
vmin
=
0
,
vmax
=
255
)
plt
.
subplot
(
1
2
2
)
plt
.
subplot
(
1
3
2
)
plt
.
imshow
(
adjusted_errors
,
cmap
=
'gray'
,
vmin
=
0
,
vmax
=
255
)
# encoded_string2 = bytes_to_bitstring(read_from_file(images[1
][:-5] + "_Compressed.txt"))
#
original_array, error_array = produce_error_array(encoded_string2, list_dic, bins, False)
#
adjusted_errors = color_adjust(abs(error_array))
#
original_array_adjusted = color_adjust(original_array)
#
plt.subplot(133)
#
plt.imshow(adjusted_errors,cmap = 'gray', vmin = 0, vmax=255)
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
)
adjusted_errors
=
color_adjust
(
abs
(
error_array
))
original_array_adjusted
=
color_adjust
(
original_array
)
plt
.
subplot
(
133
)
plt
.
imshow
(
adjusted_errors
,
cmap
=
'gray'
,
vmin
=
0
,
vmax
=
255
)
...
...
Remove_Noise.py
View file @
adf762c2
...
...
@@ -9,6 +9,7 @@ def setup_remote_sftpclient():
client
.
connect
(
"192.168.0.107"
,
username
=
"elphel"
)
sftp_client
=
client
.
open_sftp
()
return
sftp_client
def
remove_noise
(
images
,
which_sensor
):
same_sensor_images
=
[]
which_sensor
=
str
(
which_sensor
)
...
...
@@ -99,14 +100,15 @@ def find_only_in_channel(images, channel_name = "10"):
same_sensor_images
.
append
(
image_name
)
return
same_sensor_images
def
adjust_to_original
(
new_image
,
average_image
):
original_image_min
=
np
.
min
(
new_image
)
original_image_max
=
np
.
max
(
new_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 - np.array(Image.fromarray(average_image).convert("L").filter(ImageFilter.GaussianBlur(radius=4))))
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
# original_image_min = np.min(new_image)
# original_image_max = np.max(new_image)
average_image
=
average_image
-
np
.
mean
(
average_image
)
adjusted_image
=
new_image
-
average_image
# adjusted_image = new_image + (average_image - gaussian_filter(average_image,sigma=5))
# 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)
# 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
)
def
color_adjust
(
visual_array
):
...
...
@@ -136,7 +138,7 @@ def create_testable_images(images, selected_channel, quantity_of_images):
selected_images
=
np
.
array
(
images
)[
image_locations
]
# average_image = np.array(Image.open("Average_On_Channel(" + selected_channel + ").tiff"))
images_in_each_direction
=
4
images_in_each_direction
=
4
0
for
i
,
item
in
enumerate
(
selected_images
):
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
)
...
...
@@ -152,7 +154,7 @@ def create_testable_images(images, selected_channel, quantity_of_images):
altered_image
=
adjust_to_original
(
image
,
average_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)
sftp_client
.
close
()
...
...
@@ -163,7 +165,7 @@ if __name__ == "__main__":
images
=
remote_image_extractor
(
scenes
)
images
=
find_only_in_channel
(
images
,
"11"
)
# 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.show()
...
...
second_dic.npy
View file @
adf762c2
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment