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
0697219e
Commit
0697219e
authored
Jan 18, 2022
by
Nathaniel Callens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Latest experimentations with tiff images
parent
9187e090
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
20 deletions
+38
-20
compress_start.py
compress_start.py
+38
-20
No files found.
compress_start.py
View file @
0697219e
...
@@ -41,31 +41,49 @@ def image_extractor(scenes):
...
@@ -41,31 +41,49 @@ def image_extractor(scenes):
return
images
#returns a list of file paths to .tiff files in the specified directory given in file_extractor
return
images
#returns a list of file paths to .tiff files in the specified directory given in file_extractor
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
image
=
Image
.
open
(
"practice_tiff.tiff"
)
image2
=
Image
.
open
(
"practice2.tiff"
)
imarray2
=
np
.
array
(
image2
)
imarray
=
np
.
array
(
image
)
work
=
imarray2
[:,:,
0
]
ind1
,
ind2
=
np
.
random
.
randint
(
0
,
434
),
np
.
random
.
randint
(
0
,
650
)
surrounding
=
[]
for
i
,
j
in
product
(
np
.
arange
(
-
1
,
2
),
repeat
=
2
):
if
i
==
0
and
j
==
0
:
continue
else
:
surrounding
.
append
(
work
[
ind1
+
i
,
ind1
+
j
])
diff
=
[]
diff
.
append
(
np
.
max
(
surrounding
)
-
np
.
min
(
surrounding
))
print
(
surrounding
)
print
(
diff
)
"""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
as variables. Then, if statements for if row == 0 or row == maximum and if
as variables. Then, if statements for if row == 0 or row == maximum and if
col == 0 or col == maximum. Then grab corresponding open pixels. Then proceed to do
col == 0 or col == maximum. Then grab corresponding open pixels. Then proceed to do
an and statement that handles the corners"""
an and statement that handles the corners"""
tiff0
=
[]
tiff1
=
[]
tiff2
=
[]
tiff3
=
[]
files
=
os
.
listdir
(
"images"
)
scenes
=
[]
for
file
in
files
:
scene
=
os
.
path
.
join
(
"images"
,
file
)
sc
=
os
.
listdir
(
scene
)
for
s
in
sc
:
if
s
[
-
6
]
==
'0'
:
tiff0
.
append
(
os
.
path
.
join
(
scene
,
s
))
elif
s
[
-
6
]
==
'1'
:
tiff1
.
append
(
os
.
path
.
join
(
scene
,
s
))
elif
s
[
-
6
]
==
'2'
:
tiff2
.
append
(
os
.
path
.
join
(
scene
,
s
))
elif
s
[
-
6
]
==
'3'
:
tiff3
.
append
(
os
.
path
.
join
(
scene
,
s
))
diff
=
[]
for
ii
in
range
(
len
(
tiff1
)):
image
=
Image
.
open
(
tiff1
[
ii
])
image
=
np
.
array
(
image
)[
1
:,:]
ar1
,
ar2
=
image
.
shape
ind1
,
ind2
=
np
.
random
.
randint
(
0
,
ar1
),
np
.
random
.
randint
(
0
,
ar2
)
surrounding
=
[]
for
i
,
j
in
product
(
np
.
arange
(
-
1
,
2
),
repeat
=
2
):
if
i
==
0
and
j
==
0
:
continue
else
:
surrounding
.
append
(
image
[
ind1
+
i
,
ind1
+
j
])
diff
.
append
(
np
.
max
(
surrounding
)
-
np
.
min
(
surrounding
))
print
(
diff
)
"""scene_names = file_extractor()
"""scene_names = file_extractor(
"images"
)
images = image_extractor(scene_names)
images = image_extractor(scene_names)
im = Image.open(images[0])
im = Image.open(images[0])
imarray = np.array(im)
imarray = np.array(im)
...
...
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