Example #1
0
def write_pred(data,dtype=np.uint8,filename=None,size=256,band=31,number=0,pre=1):
    isExists = os.path.exists(filename)

    if not isExists:
        os.makedirs(filename)
    run=read_hyspetracal.Images()

    for i in range(batch_size):
        # for j in range(band):
        #     data1=data[i][j]
        #     print(data1.shape)
        #     data1=np.reshape(data1,(size,size))
        #     print(data1.shape)
        #     band_path=os.path.join(path[i],'band_'+str(j)+'.tif')
        #     run.write_img(filename=band_path,data=data1,width=size,height=size,
        #                   band_num=1,dtype=np.uint8)
        if pre ==0:

            band_path=os.path.join(filename,'pre_'+str(i+number)+'.tif')
            run.write_img(filename=band_path,data=data[i],width=size,height=size,
                          band_num=band,dtype=dtype)
        elif pre==1:
            band_path = os.path.join(filename, 'true_' + str(i + number) + '.tif')
            run.write_img(filename=band_path, data=data[i], width=size, height=size,
                          band_num=band, dtype=dtype)
        else:
            band_path = os.path.join(filename, 'clip_' + str(i + number) + '.tif')
            run.write_img(filename=band_path, data=data[i], width=size, height=size,
                          band_num=band, dtype=dtype)
Example #2
0
def write_pred(data, dtype=np.uint8, filename=None, size=256, band=31):
    isExists = os.path.exists(filename)

    if not isExists:
        os.makedirs(filename)

    path = []
    for i in range(batch_size):
        path1 = os.path.join(filename, str(i))
        os.makedirs(path1)
        path.append(path1)
    run = read_hyspetracal.Images()

    for i in range(batch_size):
        # for j in range(band):
        #     data1=data[i][j]
        #     print(data1.shape)
        #     data1=np.reshape(data1,(size,size))
        #     print(data1.shape)
        #     band_path=os.path.join(path[i],'band_'+str(j)+'.tif')
        #     run.write_img(filename=band_path,data=data1,width=size,height=size,
        #                   band_num=1,dtype=np.uint8)
        print(data[i].shape)
        band_path = os.path.join(path[i], '0.tif')
        run.write_img(filename=band_path,
                      data=data[i],
                      width=size,
                      height=size,
                      band_num=band,
                      dtype=np.uint8)