Commit 98096238 authored by josh's avatar josh
Browse files

init database

parent 512c9686
......@@ -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:
![](TestResults/MS/GeoEye_MS_Original.jpg)
......
......@@ -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
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" )
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment