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
Nathaniel Callens
Image Compression
Commits
0518518b
Commit
0518518b
authored
Jan 27, 2022
by
Nathaniel Callens
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
a88ba837
5bd67af5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
2 deletions
+30
-2
compress_start.py
compress_start.py
+30
-2
No files found.
compress_start.py
View file @
0518518b
...
@@ -107,13 +107,40 @@ def plot_hist(tiff_list):
...
@@ -107,13 +107,40 @@ def plot_hist(tiff_list):
diff
=
np
.
empty
((
row
,
col
))
diff
=
np
.
empty
((
row
,
col
))
diff
[
0
,:]
=
np
.
zeros
(
col
)
# keep the first row from the image
diff
[
0
,:]
=
np
.
zeros
(
col
)
# keep the first row from the image
diff
[:,
0
]
=
np
.
zeros
(
row
)
diff
[:,
0
]
=
np
.
zeros
(
row
)
predict
=
np
.
empty
([
row
,
col
])
# create a empty matrix to update prediction
predict
[
0
,:]
=
image
[
0
,:]
# keep the first row from the image
predict
[:,
0
]
=
image
[:,
0
]
# keep the first columen from the image
predict
[
-
1
,:]
=
image
[
-
1
,:]
# keep the first row from the image
predict
[:,
-
1
]
=
image
[:,
-
1
]
# keep the first columen from the image
diff
=
np
.
empty
([
row
,
col
])
diff
[
0
,:]
=
np
.
zeros
(
col
)
# keep the first row from the image
diff
[:,
0
]
=
np
.
zeros
(
row
)
diff
[
-
1
,:]
=
np
.
zeros
(
col
)
# keep the first row from the image
diff
[:,
-
1
]
=
np
.
zeros
(
row
)
for
r
in
range
(
1
,
row
-
1
):
# loop through the rth row
for
r
in
range
(
1
,
row
-
1
):
# loop through the rth row
for
c
in
range
(
1
,
col
-
1
):
# loop through the cth column
for
c
in
range
(
1
,
col
-
1
):
# loop through the cth column
surrounding
=
np
.
array
([
predict
[
r
-
1
,
c
-
1
],
predict
[
r
-
1
,
c
],
predict
[
r
-
1
,
c
+
1
],
predict
[
r
,
c
-
1
]])
surrounding
=
np
.
array
([
predict
[
r
-
1
,
c
-
1
],
predict
[
r
-
1
,
c
],
predict
[
r
-
1
,
c
+
1
],
predict
[
r
,
c
-
1
]])
predict
[
r
,
c
]
=
np
.
mean
(
surrounding
)
# take the mean of the previous 4 pixels
predict
[
r
,
c
]
=
np
.
mean
(
surrounding
)
# take the mean of the previous 4 pixels
diff
[
r
,
c
]
=
(
np
.
max
(
surrounding
)
-
np
.
min
(
surrounding
))
diff
[
r
,
c
]
=
(
np
.
max
(
surrounding
)
-
np
.
min
(
surrounding
))
predict
=
np
.
ravel
(
predict
)
diff
=
np
.
ravel
(
diff
)
n
=
len
(
predict
)
fig
=
plt
.
figure
()
ax1
=
fig
.
add_subplot
(
111
,
projection
=
'3d'
)
z3
=
np
.
zeros
(
n
)
dx
=
np
.
ones
(
n
)
dy
=
np
.
ones
(
n
)
dz
=
np
.
arange
(
n
)
ax1
.
bar3d
(
predict
,
diff
,
z3
,
dx
,
dy
,
dz
,
color
=
"red"
)
ax1
.
axis
(
'off'
)
plt
.
show
()
return
image
,
predict
,
diff
return
image
,
predict
,
diff
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
"""For boundary cases: Start by grabbing the shape of the images and saving those
"""For boundary cases: Start by grabbing the shape of the images and saving those
...
@@ -127,6 +154,7 @@ if __name__ == '__main__':
...
@@ -127,6 +154,7 @@ if __name__ == '__main__':
image
,
predict
,
difference
=
plot_hist
(
images
)
image
,
predict
,
difference
=
plot_hist
(
images
)
error
=
np
.
abs
(
image
-
predict
)
error
=
np
.
abs
(
image
-
predict
)
plot_hist
(
images
)
\ No newline at end of file
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