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
c34f9bd7
Commit
c34f9bd7
authored
Jun 13, 2022
by
Bryce Hepner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified code so now it calculates total
parent
45e246f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
WorkingPyDemo.py
WorkingPyDemo.py
+18
-5
No files found.
WorkingPyDemo.py
View file @
c34f9bd7
...
...
@@ -191,7 +191,11 @@ def make_dictionary(tiff_image_path_list, num_bins=4, difference = True):
for
_
,
tiff_image_path
in
enumerate
(
tiff_image_path_list
):
# get the image_array, etc
image_array
,
diff
,
error
=
predict_pix
(
tiff_image_path
,
difference
)
# plt.hist(np.ravel(image_array), bins=30)
# plt.xlabel('Pixel Value')
# plt.ylabel('Frequency')
# plt.title('Histogram of Pixel Values')
# plt.show()
bins
=
[
21
,
32
,
48
]
# get the boundary
boundary
=
np
.
hstack
((
image_array
[
0
,:],
image_array
[
-
1
,:],
image_array
[
1
:
-
1
,
0
],
image_array
[
1
:
-
1
,
-
1
]))
...
...
@@ -234,6 +238,11 @@ def make_dictionary(tiff_image_path_list, num_bins=4, difference = True):
mask
=
diff
>
bins
[
-
1
]
for
j
in
error
[
mask
]
.
astype
(
int
):
list_of_all_vals
[
-
1
]
.
append
(
str
(
j
))
# plt.hist([int(i) for i in list_of_all_vals[2]], bins=30)
# plt.xlabel("Error")
# plt.ylabel("Frequency")
# plt.title("Histogram of Errors")
# plt.show()
for
item
in
list_of_all_vals
:
freq
=
dict
(
Counter
(
item
))
freq
=
sorted
(
freq
.
items
(),
key
=
lambda
x
:
x
[
1
],
reverse
=
True
)
...
...
@@ -490,10 +499,11 @@ def bytes_to_bitstring(input_bytearray):
scenes
=
file_extractor
(
folder_name
)
newnamesforlater
=
[]
images
=
image_extractor
(
scenes
)
# list_dic, bins = make_dictionary(images, 4, False)
file_size_ratios
=
[]
list_dic
,
bins
=
make_dictionary
(
images
,
4
,
False
)
file_sizes_new
=
[]
file_sizes_old
=
[]
# np.save("first_dic.npy", list_dic)
for
i
in
range
(
len
(
images
)
):
for
i
in
range
(
1
):
# image, new_error, diff = huffman(images[i], 4, False)
# encoded_string = encoder(new_error, list_dic, diff, bins)
# inletters = bitstring_to_bytes(encoded_string)
...
...
@@ -504,7 +514,10 @@ for i in range(len(images)):
newnamesforlater
.
append
(
newname
+
"_Compressed.txt"
)
# with open(newname + "_Compressed.txt", 'wb') as f:
# f.write(inletters)
file_size_ratios
.
append
((
os
.
path
.
getsize
(
newname
+
"_Compressed.txt"
))
/
os
.
path
.
getsize
(
images
[
i
]))
file_sizes_new
.
append
((
os
.
path
.
getsize
(
newname
+
"_Compressed.txt"
)))
file_sizes_old
.
append
((
os
.
path
.
getsize
(
images
[
i
])))
file_sizes_new
.
append
(
os
.
path
.
getsize
(
"first_dic.npy"
))
# print(np.sum(file_sizes_new)/np.sum(file_sizes_old))
# list_dic = np.load("first_dic.npy", allow_pickle="TRUE")
# for i,item in enumerate(newnamesforlater[0:10]):
...
...
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