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
98096238
Commit
98096238
authored
Jan 21, 2021
by
josh
Browse files
init database
parent
512c9686
Changes
7
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
98096238
...
...
@@ -51,6 +51,17 @@ python ./Scripts/sliceImage.py ./TestResults/Slice/GeoEye_Original.jpg GeoEye_Sl
python ./Scripts/meanShiftSeg.py ./TestResults/MS/GeoEye_MS_Original.jpg ./TestResults/MS pyms 6 6 50
```
## "initDB.py" program:
- Sets up the base file structure
for
an image database at a given location.
## Base Dir Visual:
```
|-- ImageDatabase
│ |-- MeanShift
│ |-- Original
│ |-- Sliced
```
## Example run result:
## Original Image:

...
...
Scripts/__pycache__/ai4hdr_utils.cpython-36.pyc
View file @
98096238
No preview for this file type
Scripts/ai4hdr_utils.py
View file @
98096238
...
...
@@ -26,9 +26,6 @@ def sliceImage( imgArr: np.array, newSize: tuple ) -> dict:
}
OR empty dictionary if slicing was unable to be completed
'''
#image = cv2.imread( imagePath )
width
=
imgArr
.
shape
[
0
]
height
=
imgArr
.
shape
[
1
]
newWidth
=
newSize
[
0
]
...
...
@@ -101,7 +98,7 @@ Database file structure example:
| | | |--512x512
'''
def
initDB
(
baseDir
:
str
,
name
:
str
)
->
bool
:
def
initDB
(
dbLoc
:
str
,
name
:
str
)
->
bool
:
'''
Initialized the image database at a given directory
File Struture:
...
...
@@ -111,10 +108,9 @@ def initDB( baseDir: str, name: str ) -> bool:
│ |-- Sliced
'''
baseDir
=
pathlib
.
Path
(
baseDir
)
dbDir
=
baseDir
.
joinpath
(
name
)
dbLoc
=
pathlib
.
Path
(
dbLoc
)
dbDir
=
dbLoc
.
joinpath
(
name
)
if
dbDir
.
is_dir
():
print
(
"Failed to init: a database with this name already exists."
)
return
False
else
:
originalImagesDir
=
dbDir
.
joinpath
(
"Original"
)
...
...
@@ -124,6 +120,7 @@ def initDB( baseDir: str, name: str ) -> bool:
os
.
mkdir
(
originalImagesDir
)
os
.
mkdir
(
slicedImagesDir
)
os
.
mkdir
(
meanShiftSegDir
)
return
True
'''
...
...
@@ -206,5 +203,5 @@ def meanshift3Channel( imagePath: str, outPath: str, quantile=0.2, samples=500,
}
if
__name__
==
"__main__"
:
baseDir
=
"../"
initDB
(
baseDir
,
"ImageDatabase"
)
\ No newline at end of file
dbLoc
=
"../"
initDB
(
dbLoc
,
"ImageDatabase"
)
\ No newline at end of file
Scripts/initDB.py
0 → 100644
View file @
98096238
import
sys
import
pathlib
from
ai4hdr_utils
import
initDB
if
__name__
==
"__main__"
:
'''
Required arguments:
- arg1: location of database
- arg2: name of database
'''
if
len
(
sys
.
argv
)
==
3
:
dbLoc
=
sys
.
argv
[
1
]
dbName
=
sys
.
argv
[
2
]
success
=
initDB
(
dbLoc
=
dbLoc
,
name
=
dbName
)
dbAbsPath
=
pathlib
.
Path
(
dbLoc
).
joinpath
(
dbName
).
absolute
()
if
not
success
:
print
(
"FAILED: Database {} already exsits at {}"
.
format
(
dbName
,
dbAbsPath
)
)
else
:
print
(
"SUCCESS: Database {} created at {}"
.
format
(
dbName
,
dbAbsPath
)
)
else
:
print
(
"Invalid arg count"
)
Scripts/meanShift3Channel.py
View file @
98096238
...
...
@@ -4,8 +4,8 @@ from ai4hdr_utils import meanshift3Channel
if
__name__
==
"__main__"
:
'''
Required arguments:
- arg1: image file used for segmentation
- arg2: file name to save segmentation
- arg1: image file used for segmentation
- arg2: file name to save segmentation
'''
if
len
(
sys
.
argv
)
==
3
:
...
...
Scripts/meanShiftSeg.py
View file @
98096238
...
...
@@ -7,12 +7,12 @@ from ai4hdr_utils import meanShiftSegmentation
if
__name__
==
"__main__"
:
'''
Required arguments:
- arg1: image file used for segmentation
- arg2: directory to save results
- arg3: base name for results files
- arg4: spatial radius for ms algo
- arg5: range radius for ms algo
- arg6: min density for ms algo
- arg1: image file used for segmentation
- arg2: directory to save results
- arg3: base name for results files
- arg4: spatial radius for ms algo
- arg5: range radius for ms algo
- arg6: min density for ms algo
'''
if
len
(
sys
.
argv
)
==
7
:
...
...
Scripts/sliceImage.py
View file @
98096238
...
...
@@ -7,11 +7,11 @@ 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
- 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
:
...
...
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