# needed packages require(e1071) require(randomForest) require(automap) require(biOps) require(DMwR) require(compiler) require(parallel) # load our scripts files, where the real functions are implemented. source("spatialMatrixRegression.R") source("lista.R") source("spatialModels.R") source("funcoes.R") # transform the picture to an R matrix... nina_face <- readJpeg("data/nina_face.jpg") nina_face <- unclass(nina_face) save(nina_face, file="data/nina_face.RData") # randomly create a regression matrix according with the paper. # percents: represents the percentage of missing data, randomly selected # qtd.samples: how many times we repeat this process # could take a while... In multicore machines increase the qtd.cores parameter! obj_nina_face <- createObj(mat=nina_face, percents=.6, qtd.samples=1, radius1=10, radius2=20, radius3=30, minElementR1=2, minElementR2=5, minElementR3=10, qtd.cores=1) save(obj_nina_face, file="data/obj_nina_face.RData") # save the picture, replacing the missing locations (NA) to white pixel (255). saveNAJpg(obj_nina_face) # learn the models DEBUG <- T train.trees(obj_nina_face, "obj_nina_face") train.rfs(obj_nina_face, "obj_nina_face") train.svms(obj_nina_face, "obj_nina_face") train.base.models(obj_nina_face, "obj_nina_face") learn.autokrige.saving(obj_nina_face, "obj_nina_face", nmax=90) # transforming the predictions to jpg load("data/obj_nina_face.RData") load("data/obj_nina_face_rf.RData") saveModelJpg(obj_nina_face, rf, "rf", file.name="nina_face_rf") load("data/obj_nina_face_svm.RData") saveModelJpg(obj_nina_face, svm, "svm", file.name="nina_face_svm") load("data/obj_nina_face_tree.RData") saveModelJpg(obj_nina_face, tree, "tree", file.name="nina_face_tree") load("data/obj_nina_face_base.RData") saveModelJpg(obj_nina_face, obj_nina_face.m1, "m1", type="base", file.name="nina_face_m1") saveModelJpg(obj_nina_face, obj_nina_face.m2, "m2", type="base", file.name="nina_face_m2") saveModelJpg(obj_nina_face, obj_nina_face.m3, "m3", type="base", file.name="nina_face_m3") saveModelJpg(obj_nina_face, obj_nina_face.w1, "w1", type="base", file.name="nina_face_w1") saveModelJpg(obj_nina_face, obj_nina_face.w2, "w2", type="base", file.name="nina_face_w2") saveModelJpg(obj_nina_face, obj_nina_face.w3, "w3", type="base", file.name="nina_face_w3") load("data/obj_nina_face_autoKrige.RData") saveModelJpg(obj_nina_face, model, "kc", file.name="nina_face_kc") # Coliseum # transform the picture to R matrix... coliseum <- readJpeg("data/coliseum.jpg") coliseum <- unclass(coliseum) save(coliseum, file="data/coliseum.RData") # randomly create an regression matrix according with the paper. # percents: represents the percentage of missing data, randomly selected # qtd.samples: how many times we repeat this process # could take a while... In multicore machines increase the qtd.cores parameter! obj_coliseum <- createObj(mat=coliseum, percents=.6, qtd.samples=1, radius1=10, radius2=20, radius3=30, minElementR1=2, minElementR2=5, minElementR3=10, qtd.cores=1) save(obj_coliseum, file="data/obj_coliseum.RData") # save the picture, replacing the missing locations (NA) to white pixel (255). saveNAJpg(obj_coliseum, file.name="coliseum") # learn the models DEBUG <- T train.trees(obj_coliseum, "obj_coliseum") train.rfs(obj_coliseum, "obj_coliseum") train.svms(obj_coliseum, "obj_coliseum") train.base.models(obj_coliseum, "obj_coliseum") learn.autokrige.saving(obj_coliseum, "obj_coliseum", nmax=90) # transforming the predictions to jpg load("data/obj_coliseum.RData") load("data/obj_coliseum_rf.RData") saveModelJpg(obj_coliseum, rf, "rf", file.name="coliseum_rf") load("data/obj_coliseum_svm.RData") saveModelJpg(obj_coliseum, svm, "svm", file.name="coliseum_svm") load("data/obj_coliseum_tree.RData") saveModelJpg(obj_coliseum, tree, "tree", file.name="coliseum_tree") load("data/obj_coliseum_base.RData") saveModelJpg(obj_coliseum, obj_coliseum.m1, "m1", type="base", file.name="coliseum_m1") saveModelJpg(obj_coliseum, obj_coliseum.m2, "m2", type="base", file.name="coliseum_m2") saveModelJpg(obj_coliseum, obj_coliseum.m3, "m3", type="base", file.name="coliseum_m3") saveModelJpg(obj_coliseum, obj_coliseum.w1, "w1", type="base", file.name="coliseum_w1") saveModelJpg(obj_coliseum, obj_coliseum.w2, "w2", type="base", file.name="coliseum_w2") saveModelJpg(obj_coliseum, obj_coliseum.w3, "w3", type="base", file.name="coliseum_w3") load("data/obj_coliseum_autoKrige.RData") saveModelJpg(obj_coliseum, model, "kc", file.name="coliseum_kc")