Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ortner, Joshua
ai4hdr_backend
Commits
b973d4f1
Commit
b973d4f1
authored
Jan 24, 2021
by
Josh
Browse files
fixed slicing function
parent
c348b083
Changes
7
Hide whitespace changes
Inline
Side-by-side
Scripts/__pycache__/ai4hdr_utils.cpython-37.pyc
0 → 100644
View file @
b973d4f1
File added
Scripts/ai4hdr_utils.py
View file @
b973d4f1
...
...
@@ -23,7 +23,6 @@ def sliceImage( imgArr: np.array, newSize: tuple ) -> dict:
returns: dictionary containing the following information
{
"slicedImages": [ ( xStartPos, yStartPos, slicedImgArr ) ],
"pixelsLost" : int,
"sliceCount" : int
}
OR empty dictionary if slicing was unable to be completed
...
...
@@ -33,28 +32,28 @@ def sliceImage( imgArr: np.array, newSize: tuple ) -> dict:
newWidth
=
newSize
[
0
]
newHeight
=
newSize
[
1
]
#
r
eturn empty dictionary if desired slice is larger than image
#
R
eturn empty dictionary if desired slice is larger than image
if
newWidth
>
width
or
newHeight
>
height
:
return
{}
# all slices will be uniform, meaning
maxWidth
=
(
width
//
newWidth
)
*
newWidth
maxHeight
=
(
height
//
newHeight
)
*
newHeight
# return data
pixelsLost
=
(
width
-
maxWidth
)
+
(
height
-
maxHeight
)
# Return data
newSliceCount
=
0
imageList
=
[]
#
p
rocess image
for
i
in
range
(
0
,
maxW
idth
,
newWidth
):
for
j
in
range
(
0
,
maxH
eight
,
newHeight
):
#
P
rocess image
for
i
in
range
(
0
,
w
idth
,
newWidth
):
for
j
in
range
(
0
,
h
eight
,
newHeight
):
newSliceCount
+=
1
imageList
.
append
(
(
i
,
j
,
imgArr
[
i
:
i
+
newWidth
,
j
:
j
+
newHeight
,
:]
)
)
# Create array of zeros of slice size
base
=
np
.
zeros
(
(
newWidth
,
newHeight
,
imgArr
.
shape
[
2
]
)
)
# Slice image and broadcase to base array
# Slice will be blacked out when outside range of original image
sliceArr
=
imgArr
[
i
:
i
+
newWidth
,
j
:
j
+
newHeight
,
:]
base
[
:
sliceArr
.
shape
[
0
],
:
sliceArr
.
shape
[
1
]]
=
sliceArr
imageList
.
append
(
(
i
,
j
,
base
)
)
return
{
"slicedImages"
:
imageList
,
"pixelsLost"
:
pixelsLost
,
"sliceCount"
:
newSliceCount
}
...
...
TestResults/Slice/GeoEye_Slice-0-1024.jpg
0 → 100644
View file @
b973d4f1
79.8 KB
TestResults/Slice/GeoEye_Slice-1024-0.jpg
0 → 100644
View file @
b973d4f1
74.3 KB
TestResults/Slice/GeoEye_Slice-1024-1024.jpg
0 → 100644
View file @
b973d4f1
26.9 KB
TestResults/Slice/GeoEye_Slice-1024-512.jpg
0 → 100644
View file @
b973d4f1
77.2 KB
TestResults/Slice/GeoEye_Slice-512-1024.jpg
0 → 100644
View file @
b973d4f1
75.9 KB
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