@@ -68,16 +68,15 @@ def show_hist(parent, title, hist):
6868
6969class Histogram (Simple ):
7070 title = 'Histogram'
71- note = ['8-bit' , '16-bit' , 'rgb ' ]
71+ note = ['all ' ]
7272
7373 def run (self , ips , imgs , para = None ):
7474 msk = ips .mask ('in' )
75+ rg = np .linspace (* ips .range , 257 )
76+ img = ips .img if msk is None else ips .img [msk ]
7577 if ips .channels == 3 :
76- img = ips .img if msk is None else ips .img [msk ]
77- hist = [np .histogram (img .ravel ()[i ::3 ], np .arange (257 ))[0 ] for i in (0 ,1 ,2 )]
78- else :
79- img = ips .lookup () if msk is None else ips .lookup ()[msk ]
80- hist = np .histogram (img , np .arange (257 ))[0 ]
78+ hist = [np .histogram (img .ravel ()[i ::3 ], rg )[0 ] for i in (0 ,1 ,2 )]
79+ else : hist = np .histogram (img ,rg )[0 ]
8180 show_hist (self .app , ips .title + '-Histogram' , hist )
8281
8382class Frequence (Simple ):
@@ -94,11 +93,9 @@ def run(self, ips, imgs, para = None):
9493 msk = ips .mask ('in' )
9594 for i in range (len (imgs )):
9695 img = imgs [i ] if msk is None else imgs [i ][msk ]
97- maxv = img .max ()
98- if maxv == 0 :continue
99- ct = np .histogram (img , maxv + 1 , [0 ,maxv ])[0 ]
96+ ct = np .bincount (img .ravel ()) #np.histogram(img, maxv+1, [0,maxv])[0]
10097 titles = ['slice' ,'value' ,'count' ]
101- dt = [[ i ] * len (ct ), list ( range ( maxv + 1 )), ct ]
98+ dt = [np . ones ( len (ct ), dtype = np . uint32 ) + i , np . arange ( len ( ct )), ct ]
10299 if not para ['slice' ]:
103100 titles , dt = titles [1 :], dt [1 :]
104101 if self .para ['fre' ]:
@@ -144,27 +141,6 @@ def run(self, ips, imgs, para = None):
144141 data .append (self .count (img , para ))
145142 self .progress (n , len (imgs ))
146143 self .app .show_table (pd .DataFrame (data , columns = titles ), ips .title + '-statistic' )
147-
148- class Mark :
149- def __init__ (self , data ):
150- self .data = data
151-
152- def draw (self , dc , f , ** key ):
153- dc .SetPen (wx .Pen ((255 ,255 ,0 ), width = 1 , style = wx .SOLID ))
154- dc .SetTextForeground ((255 ,255 ,0 ))
155- font = wx .Font (8 , wx .FONTFAMILY_DEFAULT ,
156- wx .FONTSTYLE_NORMAL , wx .FONTWEIGHT_NORMAL , False )
157-
158- dc .SetFont (font )
159- data = self .data [0 if len (self .data )== 1 else key ['cur' ]]
160-
161- for i in range (len (data )):
162- pos = f (* (data [i ][0 ], data [i ][1 ]))
163- dc .SetBrush (wx .Brush ((255 ,255 ,255 )))
164- dc .DrawCircle (pos [0 ], pos [1 ], 2 )
165- dc .SetBrush (wx .Brush ((0 ,0 ,0 ), wx .BRUSHSTYLE_TRANSPARENT ))
166- dc .DrawCircle (pos [0 ], pos [1 ], data [i ][2 ]* key ['k' ])
167- dc .DrawText ('id={}, r={}' .format (i , data [i ][2 ]), pos [0 ], pos [1 ])
168144
169145class PointsValue (Simple ):
170146 title = 'Points Value'
0 commit comments