subpanel.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:bonsu 作者: bonsudev 项目源码 文件源码
def DrawROI(self):
        object = self.object
        bmp = self.image.GetBitmap()
        w =  bmp.GetWidth()
        h =  bmp.GetHeight()
        roi = [0]*6
        for i in range(3):
            roi[2*i] = int(self.roi[2*i].value.GetValue()) - 1
            roi[2*i+1] = int(self.roi[2*i+1].value.GetValue())
        axis = int(self.scrollaxis.value.GetValue())
        if axis == 1:
            x1 = int(float(w*roi[4])/float(object.shape[2]) +0.5)
            x2 = int(float(w*(roi[5]))/float(object.shape[2]) -0.5)
            y1 = int(float(h*roi[2])/float(object.shape[1]) +0.5)
            y2 = int(float(h*(roi[3]))/float(object.shape[1]) -0.5)
        elif axis == 2:
            x1 = int(float(w*roi[4])/float(object.shape[2]) +0.5)
            x2 = int(float(w*(roi[5]))/float(object.shape[2]) -0.5)
            y1 = int(float(h*roi[0])/float(object.shape[0]) +0.5)
            y2 = int(float(h*(roi[1]))/float(object.shape[0]) -0.5)
        elif axis == 3:
            x1 = int(float(w*roi[2])/float(object.shape[1]) +0.5)
            x2 = int(float(w*(roi[3]))/float(object.shape[1]) -0.5)
            y1 = int(float(h*roi[0])/float(object.shape[0]) +0.5)
            y2 = int(float(h*(roi[1]))/float(object.shape[0]) -0.5)
        self.dc = wx.MemoryDC(bmp)
        self.dc.SelectObject(bmp)
        self.dc.SetPen(wx.Pen(wx.RED, 1))
        self.dc.SetBrush(wx.TRANSPARENT_BRUSH)
        self.dc.DrawLine(x1, 1, x1, h)
        self.dc.DrawLine(x2, 1, x2, h)
        self.dc.DrawLine(1, y1, w, y1)
        self.dc.DrawLine(1, y2, w, y2)
        self.dc.SelectObject(wx.NullBitmap)
        self.image.SetBitmap(bmp)
        self.Layout()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号