-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoad.jl
More file actions
77 lines (64 loc) · 2.43 KB
/
Copy pathLoad.jl
File metadata and controls
77 lines (64 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
module Load
using Images, ProgressMeter
#=
Author: Caelan Klein
Description: Loads the images for all test sets and averages the images
=#
function loadAllImages()
names = ["Boat", "Cabinet", "Car", "Chair", "Cup", "Flashlight", "Handle", "HoseReel",
"ibook01", "imac04", "imac98", "Keyboard", "LED", "Light1", "Light2", "Mug",
"Scooter", "SprayBottle", "Stapler", "Trash"]
image_mean = zeros(Int8, 128,128)
imageVectors = Array{Gray{Float64}, 1}[]
imgFileNames = String[]
for k = 1:20
cell = names[k]
for i = 1:128
x = i - 1
imageName = "TrainingImages/" * cell * "64/UnProcessed/img_$x.png"
img = load(imageName) # load image
img = float64.(img) # convert to float
image_mean = image_mean .+ img
vecImg = vec(img)
push!(imageVectors, vecImg)
end
end
return vec(image_mean ./ 128*20), imageVectors
end
#=
Author: Riley Kopp
Description: Loads the images for a Single test set and averages the images
=#
function loadSingleImage()
image_mean = zeros(Float64, 128, 128)
k = 1
# assume images are grayscale and in /images directory
# filenames are img_#.png
imageVectors = Array{Gray{Float64}, 1}[]
imgFileNames = String[]
#generate image file names
println("Generating File Names")
for x = 0:127
fName = "TrainingImages/Boat64/UnProcessed/img_$x.png"
push!(imgFileNames, fName)
end
println("File Names Generated...\n")
# load images
println("Loading images...")
p = Progress(length(imgFileNames), 1)
for img = imgFileNames
# println("Open image: $img")
img = load(img) # load image
img = float64.(img) # convert to float
image_mean = image_mean .+ img
vecImg = vec(img)
push!(imageVectors, vecImg)
next!(p)
end
println("Images Loaded...\n")
println("Getting Image Mean")
image_mean = vec(image_mean ./ 64)
return image_mean, imageVectors
end
export loadSingleImage, loadAllImages
end