Пример #1
0
    def init_view(self, para, view, img):
        hists = [
            np.histogram(img[:, :, i], list(range(257)))[0] for i in (0, 1, 2)
        ]
        hists = [(i * (100.0 / i.max())).astype(np.uint8) for i in hists]
        self.redcvs = HistCanvas(self)
        self.redcvs.set_hist(hists[0])
        self.greencvs = HistCanvas(self)
        self.greencvs.set_hist(hists[1])
        self.bluecvs = HistCanvas(self)
        self.bluecvs.set_hist(hists[2])

        self.add_ctrl('red', self.redcvs)
        self.parse(view[0])
        self.parse(view[1])
        self.add_ctrl('green', self.greencvs)
        self.parse(view[2])
        self.parse(view[3])
        self.add_ctrl('blue', self.bluecvs)
        self.parse(view[4])
        self.parse(view[5])

        self.add_check('Preview', 'preview')
        self.add_confirm(True)
        self.reset(para)
        self.pack()
Пример #2
0
 def gray(self, hist):
     panel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
     back = wx.BoxSizer( wx.VERTICAL )
     back.Add(panel, 1, wx.EXPAND)
     sizer = wx.BoxSizer( wx.VERTICAL )
     histc = HistCanvas(panel)
     histc.set_hist(hist)
     txt = wx.StaticText( panel, wx.ID_ANY, 'Channel:'+'Gray', wx.DefaultPosition, wx.DefaultSize, 0 )
     sizer.Add( txt, 0, wx.LEFT|wx.RIGHT, 8 )
     sizer.Add( histc, 0, wx.LEFT|wx.RIGHT, 8 )
     mean, lim = np.dot(hist, range(256))/hist.sum(), np.where(hist>0)[0]
     sta = 'Statistic:   Mean:%s   Min:%s   Max:%s'%(mean.round(1), lim.min(), lim.max())
     txt = wx.StaticText( panel, wx.ID_ANY, sta, wx.DefaultPosition, wx.DefaultSize, 0 )
     sizer.Add( txt, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 8 )
     panel.SetSizer( sizer )
     self.SetSizer(back)
     self.Fit()
Пример #3
0
 def rgb(self, hist):
     panel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
     back = wx.BoxSizer( wx.VERTICAL )
     back.Add(panel, 1, wx.EXPAND)
     sizer = wx.BoxSizer( wx.VERTICAL )
     rgb = ['Red', 'Green', 'Blue']
     for i in (0,1,2):
         histc = HistCanvas(panel)
         histc.SetValue(hist[i])
         txt = wx.StaticText( panel, wx.ID_ANY, 'Channel:'+ rgb[i], wx.DefaultPosition, wx.DefaultSize, 0 )
         sizer.Add( txt, 0, wx.LEFT|wx.RIGHT, 8 )
         sizer.Add( histc, 0, wx.LEFT|wx.RIGHT, 8 )
         mean, lim = np.dot(hist[i], range(256))/hist[i].sum(), np.where(hist[i]>0)[0]
         sta = 'Statistic:   Mean:%s   Min:%s   Max:%s'%(mean.round(1), lim.min(), lim.max())
         txt = wx.StaticText( panel, wx.ID_ANY, sta, wx.DefaultPosition, wx.DefaultSize, 0 )
         sizer.Add( txt, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 8 )
     panel.SetSizer( sizer )
     self.SetSizer(back)
     self.Fit()
Пример #4
0
 def init_view(self, items, para, hist, lim):
     self.histcvs = HistCanvas(self)
     self.histcvs.set_hist(hist)
     self.lim = lim
     self.add_ctrl('hist', self.histcvs)
     ParaDialog.init_view(self, items, para, True)
Пример #5
0
 def init_view(self, items, para, hist, arange):
     self.range = arange
     self.histcvs = HistCanvas(self)
     self.histcvs.set_hist(hist)
     self.add_ctrl('hist', self.histcvs)
     ParaDialog.init_view(self, items, para, True)