Exemplo n.º 1
0
    def setup(self):
        data=read.load(self.offsets[0],file=self.filename,type=self.type)

        if self.xrange==None:
            self.xrange=[data.getBounds()[0],data.getBounds()[1]]
        if self.yrange==None:
            self.yrange=[data.getBounds()[2],data.getBounds()[3]]
Exemplo n.º 2
0
    def setup(self):
        data = read.load(self.offsets[0], file=self.filename, type=self.type)

        if self.xrange == None:
            self.xrange = [data.getBounds()[0], data.getBounds()[1]]
        if self.yrange == None:
            self.yrange = [data.getBounds()[2], data.getBounds()[3]]
Exemplo n.º 3
0
    def readData(self):


        if self.type != 'vti':
            if self.xrange[0] <=0. :
                self.data=read.load(self.offset,file=self.filenameout,type=self.type,mirrorPlane=0)
            else:
                self.data=read.load(self.offset,file=self.filenameout,type=self.type)
        else:
            self.data=read.loadvti(self.offset,file=self.filenameout)
            self.nx=self.data.nx
            self.ny=self.data.nx


        if self.xrange == None:
            self.xrange = np.array(self.data.getBounds()[0:2])
        if self.yrange == None:
            self.yrange = np.array(self.data.getBounds()[2:4])

        self.Lx = self.xrange[1] - self.xrange[0]
        self.Ly = self.yrange[1] - self.yrange[0] 
Exemplo n.º 4
0
    def readData(self):

        if self.type != 'vti':
            if self.xrange[0] <= 0.:
                self.data = read.load(self.offset,
                                      file=self.filenameout,
                                      type=self.type,
                                      mirrorPlane=0)
            else:
                self.data = read.load(self.offset,
                                      file=self.filenameout,
                                      type=self.type)
        else:
            self.data = read.loadvti(self.offset, file=self.filenameout)
            self.nx = self.data.nx
            self.ny = self.data.nx

        if self.xrange == None:
            self.xrange = np.array(self.data.getBounds()[0:2])
        if self.yrange == None:
            self.yrange = np.array(self.data.getBounds()[2:4])

        self.Lx = self.xrange[1] - self.xrange[0]
        self.Ly = self.yrange[1] - self.yrange[0]
Exemplo n.º 5
0
    def run(self):
        self.setup()
        
        offsets=np.arange(self.offsets[1]+1-self.offsets[0])+self.offsets[0]
        for offset in offsets:
            fo=''.join([self.filenameout,str(offset).zfill(4),'.png'])
            data=read.load(offset,file=self.filename,type=self.type)
            
#            exec ''.join(['var=',self.function])            
            var = self.function(data)
            self.polyplot = polyplot(var,data=data,
                                     nlevels=self.nlevels,grid=self.grid,cmap=self.cmap,
                                     orientation=self.orientation,
                                     xrange=self.xrange,yrange=self.yrange,
                                     min=self.min,max=self.max,
                                     filenameout=fo
                                     
                )
            self.polyplot.save(fo)
            plt.close()
Exemplo n.º 6
0
    def run(self):
        self.setup()

        offsets = np.arange(self.offsets[1] + 1 -
                            self.offsets[0]) + self.offsets[0]
        for offset in offsets:
            fo = ''.join([self.filenameout, str(offset).zfill(4), '.png'])
            data = read.load(offset, file=self.filename, type=self.type)

            #            exec ''.join(['var=',self.function])
            var = self.function(data)
            self.polyplot = polyplot(var,
                                     data=data,
                                     nlevels=self.nlevels,
                                     grid=self.grid,
                                     cmap=self.cmap,
                                     orientation=self.orientation,
                                     xrange=self.xrange,
                                     yrange=self.yrange,
                                     min=self.min,
                                     max=self.max,
                                     filenameout=fo)
            self.polyplot.save(fo)
            plt.close()
Exemplo n.º 7
0
def getFromOffset(offset, filenameout='data', type='pvtu'):
    data = read.load(offset, file=filenameout, type=type)
    myradii = get(data)
    myradii['offset'] = offset
    return myradii
Exemplo n.º 8
0
def getFromOffset(offset,filenameout='data',type='pvtu'):
    data = read.load(offset,file=filenameout,type=type)
    myradii=get(data)
    myradii['offset'] = offset
    return myradii
Exemplo n.º 9
0
def output():
    file = os.listdir(data_dir)
    filesp = file[0].split('.')
    imgwritpath = write_dir + file[0]
    writepath = write_dir + filesp[0] + '.xml'
    collection['file'] = file[0]
    read_path = data_dir + file[0]

    ## png图片
    # img = cv.imread(read_path)

    # ###  原图
    img = read.load(read_path)
    img = cv.flip(img, 0, dst=None)

    ## 1 归一化到0,255的数据
    # image= img/255
    ## 2 截取到-0.75,0.75区间的数据/3
    img = np.expand_dims(img, -1)

    imgShape = np.shape(img)
    collection['shape'] = imgShape
    inputTest = np.expand_dims(img, 0)
    x = tf.placeholder(tf.float32,
                       shape=[1, imgShape[0], imgShape[1], channel])
    y = U_net.inference(x, is_training=False)
    variables_to_restore = []
    for v in tf.global_variables():
        variables_to_restore.append(v)
    saver = tf.train.Saver(variables_to_restore,
                           write_version=tf.train.SaverDef.V2,
                           max_to_keep=None)
    tf.global_variables_initializer().run()
    saver.restore(sess, savepath)
    output = sess.run(y, feed_dict={x: inputTest})

    out = np.squeeze(output).astype(np.uint8)

    ## 1 归一化到0,255的数据
    # out = out*255
    ## 2 截取到-0.75,0.75区间的数据
    # img = ((np.squeeze(img) + 0.75) / 1.5 * 255).astype(np.uint8)
    # out = out * 255
    ## 3 映射到0,1的数据
    img = ((np.squeeze(inputTest)) * 255).astype(np.uint8)
    out = np.squeeze(output).astype(np.uint8)
    out = out * 255

    kernel = cv.getStructuringElement(cv.MORPH_RECT, (5, 5))  # 定义结构元素
    outclosing = cv.morphologyEx(out, cv.MORPH_CLOSE, kernel)  # 闭运算
    postproce.contourmask(img, outclosing, collection)
    wrx.writeInfoToXml(writepath, collection)
    # cv.imwrite(imgwritpath,img)
    cv.namedWindow('imgrec', 0)
    cv.resizeWindow('imgrec', 500, 500)
    cv.imshow('imgrec', img)
    cv.namedWindow('output', 0)
    cv.resizeWindow('output', 500, 500)
    cv.imshow('output', outclosing)
    cv.waitKey(0)
    cv.destroyAllWindows()