README.md 6.88 KB
Newer Older
Ortner, Joshua's avatar
Ortner, Joshua committed
1
2
# ai4hdr_backend

3
4
5
6
7
## "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.

8
9
10
11
12
13
14
15
## 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:
16
```bash
josh's avatar
josh committed
17
python ./Scripts/sliceImage.py ./TestResults/Slice/GeoEye_Original.jpg GeoEye_Slice 512 512 ./TestResults/Slice/
josh's avatar
josh committed
18
19
```

20
## Example run result:
josh's avatar
readme    
josh committed
21
## Original Image: 1180x1180
josh's avatar
josh committed
22
![](TestResults/Slice/GeoEye_Original.jpg)
josh's avatar
josh committed
23

josh's avatar
readme    
josh committed
24
## Slice 1: 512x512
josh's avatar
josh committed
25
![](TestResults/Slice/GeoEye_Slice-0-0.jpg)
josh's avatar
josh committed
26

josh's avatar
readme    
josh committed
27
## Slice 2: 512x512
josh's avatar
josh committed
28
![](TestResults/Slice/GeoEye_Slice-0-512.jpg)
josh's avatar
josh committed
29

josh's avatar
readme    
josh committed
30
## Slice 3: 512x512
josh's avatar
josh committed
31
![](TestResults/Slice/GeoEye_Slice-512-0.jpg)
josh's avatar
josh committed
32

josh's avatar
readme    
josh committed
33
## Slice 4: 512x512
josh's avatar
josh committed
34
![](TestResults/Slice/GeoEye_Slice-512-512.jpg)
35

josh's avatar
josh committed
36
37
38
39
40
41
42
43
44
45
46
47
| 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)  |

48
49

## "meanShiftSeg.py" program:
josh's avatar
readme    
josh committed
50
51
 - Uses the pymeanshift library to create a segmented images
 - Install pymeanshift: pip install git+git://github.com/fjean/pymeanshift.git
52
53
54
55
56
57
58
59
60

## 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

61
## Example run:
62
 ```bash
josh's avatar
josh committed
63
python ./Scripts/meanShiftSeg.py ./TestResults/MS/GeoEye_MS_Original.jpg ./TestResults/MS pyms 6 6 50
64
65
```

josh's avatar
josh committed
66
67
68
## Example run result:
## Original Image:
![](TestResults/MS/GeoEye_MS_Original.jpg)
69

josh's avatar
josh committed
70
71
72
73
| Segmentation Image  | Labels Image |
| ------------- | ------------- |
| ![](TestResults/MS/pyms-color-seg.jpg)  | ![](TestResults/MS/pyms-labels-image.jpg)  |

74

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
## "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
```

178
## "meanShift3Channel.py" program:
179
180
181
182
183
184
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

185
## Example run:
186
 ```bash
josh's avatar
josh committed
187
python ./Scripts/meanShift3Channel.py ./TestResults/MS/GeoEye_MS_Original.jpg ./TestResults/MS/three-channel-seg
188
189
190
191
```

 ## Example run result:
 ## Original Image:
josh's avatar
josh committed
192
 ![](TestResults/MS/GeoEye_MS_Original.jpg)
193
194

 ## Segmentation Image:
josh's avatar
josh committed
195
 ![](TestResults/MS/three-channel-seg.jpg)
196
197

 ## Program run time:
198
199
200
 This program takes roughly 20 seconds to run, tested on an AMD FX(tm)-4300 Quad-Core Processor