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
9d6dc3a6
Commit
9d6dc3a6
authored
Jun 15, 2022
by
Bryce Hepner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small changes for tests
parent
d94c08ed
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
12 deletions
+9
-12
RunningInParallel.py
RunningInParallel.py
+2
-2
WorkingPyDemo.py
WorkingPyDemo.py
+7
-10
No files found.
RunningInParallel.py
View file @
9d6dc3a6
...
@@ -22,7 +22,7 @@ if __name__ == "__main__":
...
@@ -22,7 +22,7 @@ if __name__ == "__main__":
def
save_an_image
(
filename
):
def
save_an_image
(
filename
):
"""
"""
Takes in the filename and writes the compressed image
"""
"""
newnamesforlater
=
[]
newnamesforlater
=
[]
list_dic
=
np
.
load
(
"first_dic.npy"
,
allow_pickle
=
True
)
list_dic
=
np
.
load
(
"first_dic.npy"
,
allow_pickle
=
True
)
...
@@ -47,6 +47,6 @@ if __name__ == "__main__":
...
@@ -47,6 +47,6 @@ if __name__ == "__main__":
newname
=
filename
[:
-
4
]
newname
=
filename
[:
-
4
]
encoded_string2
=
bytes_to_bitstring
(
read_from_file
(
newname
+
"_Compressed.txt"
))
encoded_string2
=
bytes_to_bitstring
(
read_from_file
(
newname
+
"_Compressed.txt"
))
reconstruct_image
=
decoder
(
encoded_string2
,
list_dic
,
bins
,
False
)
reconstruct_image
=
decoder
(
encoded_string2
,
list_dic
,
bins
,
False
)
dview
.
map_sync
(
save_an_image
,
images
[
200
:
])
dview
.
map_sync
(
save_an_image
,
images
[
160
:
200
])
# dview.map_sync(decode_an_image, images[0:6])
# dview.map_sync(decode_an_image, images[0:6])
print
(
time
()
-
starttime
)
print
(
time
()
-
starttime
)
\ No newline at end of file
WorkingPyDemo.py
View file @
9d6dc3a6
...
@@ -506,29 +506,27 @@ if __name__ == "__main__":
...
@@ -506,29 +506,27 @@ if __name__ == "__main__":
scenes
=
file_extractor
(
folder_name
)
scenes
=
file_extractor
(
folder_name
)
images
=
image_extractor
(
scenes
)
images
=
image_extractor
(
scenes
)
newnamesforlater
=
[]
newnamesforlater
=
[]
# print(len(images))
# list_dic, bins = make_dictionary(images, 4, False)
# list_dic, bins = make_dictionary(images, 4, False)
file_sizes_new
=
[]
file_sizes_new
=
[]
file_sizes_old
=
[]
file_sizes_old
=
[]
# np.save("first_dic.npy", list_dic)
# np.save("first_dic.npy", list_dic)
for
i
in
range
(
200
,
len
(
images
)):
for
i
in
range
(
len
(
images
)):
#
image, new_error, diff = huffman(images[i], 4, False)
image
,
new_error
,
diff
=
huffman
(
images
[
i
],
4
,
False
)
#
encoded_string = encoder(new_error, list_dic, diff, bins)
encoded_string
=
encoder
(
new_error
,
list_dic
,
diff
,
bins
)
#
inletters = bitstring_to_bytes(encoded_string)
inletters
=
bitstring_to_bytes
(
encoded_string
)
if
images
[
i
][
-
5
:]
==
".tiff"
:
if
images
[
i
][
-
5
:]
==
".tiff"
:
newname
=
images
[
i
][:
-
5
]
newname
=
images
[
i
][:
-
5
]
else
:
else
:
newname
=
images
[
i
][:
-
4
]
newname
=
images
[
i
][:
-
4
]
# print(newname)
newnamesforlater
.
append
(
newname
+
"_Compressed.txt"
)
newnamesforlater
.
append
(
newname
+
"_Compressed.txt"
)
#
with open(newname + "_Compressed.txt", 'wb') as f:
with
open
(
newname
+
"_Compressed.txt"
,
'wb'
)
as
f
:
#
f.write(inletters)
f
.
write
(
inletters
)
file_sizes_new
.
append
((
os
.
path
.
getsize
(
newname
+
"_Compressed.txt"
)))
file_sizes_new
.
append
((
os
.
path
.
getsize
(
newname
+
"_Compressed.txt"
)))
file_sizes_old
.
append
((
os
.
path
.
getsize
(
images
[
i
])))
file_sizes_old
.
append
((
os
.
path
.
getsize
(
images
[
i
])))
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
))
# list_dic = np.load("first_dic.npy", allow_pickle="TRUE")
# list_dic = np.load("first_dic.npy", allow_pickle="TRUE")
# bins = [21,32,48]
# bins = [21,32,48]
# starttime = time()
# starttime = time()
...
@@ -537,7 +535,6 @@ print(np.sum(file_sizes_new)/np.sum(file_sizes_old))
...
@@ -537,7 +535,6 @@ print(np.sum(file_sizes_new)/np.sum(file_sizes_old))
# encoded_string2 = bytes_to_bitstring(read_from_file(item))
# encoded_string2 = bytes_to_bitstring(read_from_file(item))
# reconstruct_image = decoder(encoded_string2, list_dic, bins, False)
# reconstruct_image = decoder(encoded_string2, list_dic, bins, False)
# print(np.allclose(image, reconstruct_image))
# print(np.allclose(image, reconstruct_image))
# print(time()-starttime)
# text_to_tiff("images/1626033496_437803/1626033496_437803_3._Compressed.txt", list_dic, bins)
# 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")
# original_image = Image.open("images/1626033496_437803/1626033496_437803_3.tiff")
# original_image = np.array(original_image)[1:]
# original_image = np.array(original_image)[1:]
...
...
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