# 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 ./Scripts/sliceImage.py ./TestResults/Slice/GeoEye_Original.jpg GeoEye_Slice 512 512 ./TestResults/Slice/ ``` ## Example run result: ## Original Image: 1180x1180 ![](TestResults/Slice/GeoEye_Original.jpg) ## Slice 1: 512x512 ![](TestResults/Slice/GeoEye_Slice-0-0.jpg) ## Slice 2: 512x512 ![](TestResults/Slice/GeoEye_Slice-0-512.jpg) ## Slice 3: 512x512 ![](TestResults/Slice/GeoEye_Slice-512-0.jpg) ## Slice 4: 512x512 ![](TestResults/Slice/GeoEye_Slice-512-512.jpg) | Original Image | | ------------- | ------------- | | ![](TestResults/Slice/GeoEye_Original.jpg) | | ------------- | ------------- | | Slice 1 | Slice 2 | | ------------- | ------------- | | ![](TestResults/Slice/GeoEye_Slice-0-0.jpg) | ![](TestResults/Slice/GeoEye_Slice-0-512.jpg) | | ------------- | ------------- | | Slice 3 | Slice 4 | | ------------- | ------------- | | ![](TestResults/Slice/GeoEye_Slice-512-0.jpg) | ![](TestResults/Slice/GeoEye_Slice-512-512.jpg) | ## "meanShiftSeg.py" program: - Uses the pymeanshift library to create a segmented images - Install pymeanshift: pip install git+git://github.com/fjean/pymeanshift.git ## Command line 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 ## Example run: ```bash python ./Scripts/meanShiftSeg.py ./TestResults/MS/GeoEye_MS_Original.jpg ./TestResults/MS pyms 6 6 50 ``` ## Example run result: ## Original Image: ![](TestResults/MS/GeoEye_MS_Original.jpg) | Segmentation Image | Labels Image | | ------------- | ------------- | | ![](TestResults/MS/pyms-color-seg.jpg) | ![](TestResults/MS/pyms-labels-image.jpg) | ## "initDB.py" program: - Sets up the base file structure for an image database at a given location. ## Example run: ```bash python Scripts/initDB.py ../ ImageDatabase ``` ## Directory Structure Result: ``` ├── ImageDatabase │   ├── MeanShift │   ├── Original │   └── Sliced ``` ## "importAndProcess.py" - Import and process image ## Example run: ```bash python Scripts/importAndProcessImage.py TestResults/MS/GeoEye_MS_Original.jpg ../ImageDatabase/ GeoEye ``` ## Database Directory Result: ``` ├── MeanShift │   └── GeoEye-0 │   ├── 128 │   │   ├── GeoEye-0-0-color-seg.jpg │   │   ├── GeoEye-0-0-labels-image.jpg │   │   ├── GeoEye-0-128-color-seg.jpg │   │   ├── GeoEye-0-128-labels-image.jpg │   │   ├── GeoEye-0-256-color-seg.jpg │   │   ├── GeoEye-0-256-labels-image.jpg │   │   ├── GeoEye-0-384-color-seg.jpg │   │   ├── GeoEye-0-384-labels-image.jpg │   │   ├── GeoEye-128-0-color-seg.jpg │   │   ├── GeoEye-128-0-labels-image.jpg │   │   ├── GeoEye-128-128-color-seg.jpg │   │   ├── GeoEye-128-128-labels-image.jpg │   │   ├── GeoEye-128-256-color-seg.jpg │   │   ├── GeoEye-128-256-labels-image.jpg │   │   ├── GeoEye-128-384-color-seg.jpg │   │   ├── GeoEye-128-384-labels-image.jpg │   │   ├── GeoEye-256-0-color-seg.jpg │   │   ├── GeoEye-256-0-labels-image.jpg │   │   ├── GeoEye-256-128-color-seg.jpg │   │   ├── GeoEye-256-128-labels-image.jpg │   │   ├── GeoEye-256-256-color-seg.jpg │   │   ├── GeoEye-256-256-labels-image.jpg │   │   ├── GeoEye-256-384-color-seg.jpg │   │   ├── GeoEye-256-384-labels-image.jpg │   │   ├── GeoEye-384-0-color-seg.jpg │   │   ├── GeoEye-384-0-labels-image.jpg │   │   ├── GeoEye-384-128-color-seg.jpg │   │   ├── GeoEye-384-128-labels-image.jpg │   │   ├── GeoEye-384-256-color-seg.jpg │   │   ├── GeoEye-384-256-labels-image.jpg │   │   ├── GeoEye-384-384-color-seg.jpg │   │   └── GeoEye-384-384-labels-image.jpg │   ├── 256 │   │   ├── GeoEye-0-0-color-seg.jpg │   │   ├── GeoEye-0-0-labels-image.jpg │   │   ├── GeoEye-0-256-color-seg.jpg │   │   ├── GeoEye-0-256-labels-image.jpg │   │   ├── GeoEye-256-0-color-seg.jpg │   │   ├── GeoEye-256-0-labels-image.jpg │   │   ├── GeoEye-256-256-color-seg.jpg │   │   └── GeoEye-256-256-labels-image.jpg │   └── 512 │   ├── GeoEye-0-0-color-seg.jpg │   └── GeoEye-0-0-labels-image.jpg ├── Original │   └── GeoEye-0.jpg └── Sliced └── GeoEye-0 ├── 128 │   ├── GeoEye-0-0.jpg │   ├── GeoEye-0-128.jpg │   ├── GeoEye-0-256.jpg │   ├── GeoEye-0-384.jpg │   ├── GeoEye-128-0.jpg │   ├── GeoEye-128-128.jpg │   ├── GeoEye-128-256.jpg │   ├── GeoEye-128-384.jpg │   ├── GeoEye-256-0.jpg │   ├── GeoEye-256-128.jpg │   ├── GeoEye-256-256.jpg │   ├── GeoEye-256-384.jpg │   ├── GeoEye-384-0.jpg │   ├── GeoEye-384-128.jpg │   ├── GeoEye-384-256.jpg │   └── GeoEye-384-384.jpg ├── 256 │   ├── GeoEye-0-0.jpg │   ├── GeoEye-0-256.jpg │   ├── GeoEye-256-0.jpg │   └── GeoEye-256-256.jpg └── 512 └── GeoEye-0-0.jpg ``` ## "meanShift3Channel.py" program: Uses the mean shift algorithm to create a segmentation mask for an image. ## Command line arguments: - arg1: image file used for segmentation - arg2: file name to save segmentation ## Example run: ```bash python ./Scripts/meanShift3Channel.py ./TestResults/MS/GeoEye_MS_Original.jpg ./TestResults/MS/three-channel-seg ``` ## Example run result: ## Original Image: ![](TestResults/MS/GeoEye_MS_Original.jpg) ## Segmentation Image: ![](TestResults/MS/three-channel-seg.jpg) ## Program run time: This program takes roughly 20 seconds to run, tested on an AMD FX(tm)-4300 Quad-Core Processor