Exemplo n.º 1
0
# imgs_path = "/home/kaue/data/extracted_images/red_band"
imgs_path = "/home/kaue/data/extracted_images/newextracted"


img_list = msc.orderedFileList(imgs_path,extension='*.png')

img_list = sorted(img_list)

# del img_list[0:225]

print(img_list[0:5])

for i,img_path in enumerate(img_list):
    t1 = time.time()

    img_name = msc.fileNumberFromPathAsStr(img_path)
    out_orig = os.path.join(vd.PREDS_PATH,img_name+'.png')
    out_pred = os.path.join(vd.PREDS_PATH,img_name+'_pred.png')

    dest_orig = os.path.join(outpaths['orig_resiz'],img_name+'.png')
    dest_pred = os.path.join(outpaths['masks'],img_name+'.png')

    dest_onlyveg = os.path.join(outpaths['only_veg'],img_name+'.png')

    dest_ndvi = os.path.join(outpaths['ndvi'],img_name+'.png')
    dest_overlay = os.path.join(outpaths['overlay'],img_name+'.png')

    try:
        if not os.path.isfile(dest_pred):
            vd.single_img_forward_pass(epoch_path,img_path)
Exemplo n.º 2
0
from processing_functions import misc as msc
from processing_functions import color_stuff as cs
import os

path = "/home/kaue/data/politecnico_v2/val"
destpath = "/home/kaue/data/politecnico_v2/downsized"

filelist = msc.orderedFileList(path)

for filepath in filelist:
    filename = msc.fileNumberFromPathAsStr(filepath)+'.png'
    print(filename)
    cs.allBlackImg(filepath,os.path.join(destpath,filename),(512,512))
Exemplo n.º 3
0
#create file to store the last opened image:
lastOpenedPath = os.path.join(basePath,'last_opened.txt')

if not os.path.exists(lastOpenedPath):
    # storageFile = open(lastOpenedPath,'w')
    # storageFile.close()
    msc.writeToFile(lastOpenedPath,"")

if os.stat(lastOpenedPath).st_size == 0:
    # storageFile = open(lastOpenedPath,'w')
    # storageFile.write("-1")
    # storageFile.close()]
    msc.writeToFile(lastOpenedPath,"-1")


for filePath in filePathList:

    fileNumber = msc.fileNumberFromPath(filePath)
    # print(msc.readNumberFromFile(lastOpenedPath))
    if msc.readNumberFromFile(lastOpenedPath) < fileNumber: 
        fname = msc.fileNumberFromPathAsStr(filePath)+'.jpg'
        print(fname)
        fpath2 = os.path.join(basePath2,fname)
        print(fpath2)
        print(filePath)
        os.system("kolourpaint "+filePath+" &")
        os.system("eog "+fpath2)
        # os.system("gimp "+filePath)
        msc.writeToFile(lastOpenedPath,str(fileNumber))

Exemplo n.º 4
0
classifiedPath = "/home/kaue/data/extracted_images/gt/only_trees"
toClassifyFolder = "/home/kaue/data/extracted_images/gt/originals"

originalsPath = "/home/kaue/data/extracted_images/2019-07-11-16-21-46/ngr"

classifiedList = misc.orderedFileList(classifiedPath, '*.png')

for path in classifiedList:
    # print(path)
    filename = misc.filenameFromPath(path)
    # print(filename)
    originalImgPath = os.path.join(originalsPath,
                                   misc.modFilenameExt(filename, '.jpg'))
    outPath = os.path.join(toClassifyFolder,
                           misc.fileNumberFromPathAsStr(filename) + '.png')

    print(originalImgPath, outPath, filename)

    # classifiedImg = cv2.imread(path)
    originalImg = cv2.imread(originalImgPath)

    # for i,column in enumerate(classifiedImg):
    #     for j,pixel in enumerate(column):
    #         # as there are only black or white pixels, we can test only a channel
    #         # print(originalImg[i,j,0])
    #         if pixel[0] == 255:
    #             try:
    #                 pixel.itemset(0,originalImg[i,j,0])
    #                 pixel.itemset(1,originalImg[i,j,1])
    #                 pixel.itemset(2,originalImg[i,j,2])
Exemplo n.º 5
0
# outpath = "/home/kauevestena/data/extracted_images/transformed/teste_b.jpg"

# mn.save_one_band(impath,outpath)

# img = cv2.imread("/home/kauevestena/testes/CamVid/test/0001TP_007170.png")
# cv2.imshow("teste",img)
# cv2.waitKey(0)


folderlist =[
    "/home/kaue/data/extracted_images/2019-07-11-16-21-46/ngr"
]

OutPthList = [
    "/home/kaue/data/extracted_images/nir_band",
    "/home/kaue/data/extracted_images/red_band"
]

for folder in folderlist:
    print(folder)
    # for filepath in glob.glob(os.path.join(folder,"*.png'")):
    # joinedpath = os.path.join(folder,"")
    for filepath in glob.glob(folder+"/*.jpg"):
        # print(filepath)
        fileName = msc.fileNumberFromPathAsStr(filepath)
        mn.save_one_band(filepath,os.path.join(OutPthList[0],fileName+'.png'),channel=0)
        mn.save_one_band(filepath,os.path.join(OutPthList[1],fileName+'.png'))


msc.telegram_bot_sendtext("band extraction terminated")
Exemplo n.º 6
0
 def __init__(self, imgpath):
     self.img_path = imgpath
     self.img_name = msc.filenameFromPath(imgpath)
     self.img_number = msc.fileNumberFromPathAsStr(imgpath)