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
9d5cbb08
Commit
9d5cbb08
authored
Aug 05, 2022
by
Bryce Hepner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed while making graphs
parent
e8a6c815
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
245 additions
and
81 deletions
+245
-81
GraphMaker.ipynb
GraphMaker.ipynb
+229
-65
WorkingPyDemo.py
WorkingPyDemo.py
+16
-16
No files found.
GraphMaker.ipynb
View file @
9d5cbb08
This source diff could not be displayed because it is too large. You can
view the blob
instead.
WorkingPyDemo.py
View file @
9d5cbb08
...
@@ -205,7 +205,7 @@ def make_dictionary(tiff_image_path_list, num_bins=4, difference = True):
...
@@ -205,7 +205,7 @@ def make_dictionary(tiff_image_path_list, num_bins=4, difference = True):
# plt.title('Histogram of Pixel Values')
# plt.title('Histogram of Pixel Values')
# plt.show()
# plt.show()
bins
=
[
2
9
,
44
,
67
]
bins
=
[
2
1
,
32
,
48
]
# get the boundary
# get the boundary
boundary
=
np
.
hstack
((
image_array
[
0
,:],
image_array
[
-
1
,:],
image_array
[
1
:
-
1
,
0
],
image_array
[
1
:
-
1
,
-
1
]))
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):
...
@@ -290,7 +290,7 @@ def huffman(tiff_image_path, num_bins=4, difference = True):
# get the image_as_array, etc
# get the image_as_array, etc
image_as_array
,
diff
,
error
=
predict_pix
(
tiff_image_path
,
difference
)
image_as_array
,
diff
,
error
=
predict_pix
(
tiff_image_path
,
difference
)
bins
=
[
2
9
,
44
,
67
]
bins
=
[
2
1
,
32
,
48
]
# get the boundary
# 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
]))
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__":
...
@@ -548,16 +548,16 @@ if __name__ == "__main__":
scenes
=
file_extractor
(
"images"
)
scenes
=
file_extractor
(
"images"
)
images
=
image_extractor
(
scenes
)
images
=
image_extractor
(
scenes
)
newnamesforlater
=
[]
newnamesforlater
=
[]
list_dic
,
bins
=
make_dictionary
(
images
,
4
,
Tru
e
)
list_dic
,
bins
=
make_dictionary
(
images
,
4
,
Fals
e
)
file_sizes_new
=
[]
file_sizes_new
=
[]
file_sizes_old
=
[]
file_sizes_old
=
[]
# list_dic = np.load("first_dict.npy", allow_pickle="True")
# list_dic = np.load("first_dict.npy", allow_pickle="True")
bins
=
[
2
9
,
44
,
67
]
bins
=
[
2
1
,
32
,
48
]
#otherbins = [21,32,48]
#otherbins = [21,32,48]
np
.
save
(
"first_dict.npy"
,
list_dic
)
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
,
Tru
e
)
image
,
new_error
,
diff
=
huffman
(
images
[
i
],
4
,
Fals
e
)
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
)
...
@@ -578,16 +578,16 @@ if __name__ == "__main__":
...
@@ -578,16 +578,16 @@ if __name__ == "__main__":
file_sizes_new
.
append
(
os
.
path
.
getsize
(
"first_dict.npy"
))
file_sizes_new
.
append
(
os
.
path
.
getsize
(
"first_dict.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_dict.npy", allow_pickle="TRUE")
# list_dic = np.load("first_dict.npy", allow_pickle="TRUE")
bins
=
[
2
9
,
44
,
67
]
bins
=
[
2
1
,
32
,
48
]
#
for i,item in enumerate(newnamesforlater):
for
i
,
item
in
enumerate
(
newnamesforlater
):
#
print(item)
#
print(item)
#
image, new_error, diff = huffman(images[i], 4, False)
image
,
new_error
,
diff
=
huffman
(
images
[
i
],
4
,
False
)
#
encoded_string2 = bytes_to_bitstring(read_from_file(item))
encoded_string2
=
bytes_to_bitstring
(
read_from_file
(
item
))
#
starttime = time()
starttime
=
time
()
#
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)
#
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