Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ortner, Joshua
ai4hdr_backend
Commits
05bd31fd
Commit
05bd31fd
authored
Jan 20, 2021
by
josh
Browse files
created distinct py program to run image sliceing
parent
580cf343
Changes
5
Hide whitespace changes
Inline
Side-by-side
.vscode/settings.json
0 → 100644
View file @
05bd31fd
{
"python.linting.enabled"
:
false
}
\ No newline at end of file
README.md
View file @
05bd31fd
# ai4hdr_backend
## "sliceImage.py" program:
Slices an image into even sized tiles.
Note: if the slice size doesn't fit evenly into the size of
the original image, pixels will be lost.
## Command line arguments
-
arg1: name of image file used for slicing
-
arg2: file name used as base for all slices
-
arg3: width of new slices
-
arg4: height of new slices
-
arg5: directory to save slices
## Example run
```
bash
python sliceImage.py ../image_database/GeoEye_After011310.jpg base 512 512 ../image_database/
```
\ No newline at end of file
__pycache__/ai4hdr_utils.cpython-36.pyc
0 → 100644
View file @
05bd31fd
File added
ai4hdr_utils.py
View file @
05bd31fd
...
...
@@ -8,14 +8,14 @@ def meanshiftSegmentation( image ):
pass
def
sliceImage
(
imagePath
:
str
,
newFileBase
:
str
,
newSize
:
tuple
,
newPath
:
str
=
False
)
->
int
:
def
sliceImage
(
imagePath
:
str
,
newFileBase
:
str
,
newSize
:
tuple
,
newPath
:
str
)
->
int
:
'''
Creates slices of images given
imagePath : path to image used for slicing
newFileBase: used to rename each slice
newSize : width and height of new slices
newPath : where to save new slices
, cwd by defaul
t
newPath : where to save new slicest
returns: dictionary containing the following information
{
...
...
@@ -25,14 +25,9 @@ def sliceImage( imagePath: str, newFileBase: str, newSize: tuple, newPath: str=F
}
OR empty dictionary if slicing was unable to be completed
'''
if
not
newPath
:
newPath
=
pathlib
.
Path
.
cwd
()
else
:
newPath
=
pathlib
.
Path
(
newPath
)
newPath
=
pathlib
.
Path
(
newPath
)
image
=
cv2
.
imread
(
imagePath
)
print
(
image
.
shape
)
width
=
image
.
shape
[
0
]
height
=
image
.
shape
[
1
]
...
...
@@ -66,12 +61,4 @@ def sliceImage( imagePath: str, newFileBase: str, newSize: tuple, newPath: str=F
"pixelsLost"
:
pixelsLost
,
"sliceCount"
:
newSliceCount
,
"slicePaths"
:
newPaths
}
if
__name__
==
"__main__"
:
cwd
=
pathlib
.
Path
.
cwd
()
imgPath
=
cwd
.
joinpath
(
"GeoEye_After011310.jpg"
)
newFileBase
=
"GeoEye_Slice"
newPath
=
cwd
.
joinpath
(
"sliced_images"
)
sliceImage
(
str
(
imgPath
),
newFileBase
,
(
512
,
512
),
newPath
=
str
(
newPath
)
)
\ No newline at end of file
}
\ No newline at end of file
sliceImage.py
0 → 100644
View file @
05bd31fd
import
sys
from
ai4hdr_utils
import
sliceImage
if
__name__
==
"__main__"
:
'''
Required arguments:
- arg1: image file used for slicing
- arg2: file name used as base for all slices
- arg3: width of new slices
- arg4: height of new slices
- arg5: directory to save slices
'''
if
len
(
sys
.
argv
)
==
6
:
imagePath
=
sys
.
argv
[
1
]
newFileBase
=
sys
.
argv
[
2
]
newSize
=
(
int
(
sys
.
argv
[
3
]
),
int
(
sys
.
argv
[
4
]
)
)
newPath
=
sys
.
argv
[
5
]
sliceImage
(
imagePath
,
newFileBase
,
newSize
,
newPath
)
else
:
print
(
"Invalid arg count"
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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