Commit 39171fc5d0cfe0f0955d44d823bbe0be9651fe7c

Authored by tfmoraes
1 parent b0529683

ENH: Plotting histogram in the clut widget

Showing 1 changed file with 10 additions and 8 deletions   Show diff stats
invesalius/gui/widgets/clut_raycasting.py
@@ -34,7 +34,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -34,7 +34,7 @@ class CLUTRaycastingWidget(wx.Panel):
34 self.padding = 10 34 self.padding = 10
35 self.to_render = False 35 self.to_render = False
36 self.histogram_pixel_points = [[0,0]] 36 self.histogram_pixel_points = [[0,0]]
37 - self.histogram_array = [[100,100],[100,100]] 37 + self.histogram_array = [100,100]
38 self.CreatePixelArray() 38 self.CreatePixelArray()
39 #self.sizer = wx.BoxSizer(wx.HORIZONTAL) 39 #self.sizer = wx.BoxSizer(wx.HORIZONTAL)
40 #self.SetSizer(self.sizer) 40 #self.SetSizer(self.sizer)
@@ -293,6 +293,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -293,6 +293,7 @@ class CLUTRaycastingWidget(wx.Panel):
293 x,y = self.histogram_pixel_points[0] 293 x,y = self.histogram_pixel_points[0]
294 print "=>", x,y 294 print "=>", x,y
295 ctx.move_to(x,y) 295 ctx.move_to(x,y)
  296 + ctx.set_line_width(0.5)
296 for x,y in self.histogram_pixel_points: 297 for x,y in self.histogram_pixel_points:
297 ctx.line_to(x,y) 298 ctx.line_to(x,y)
298 ctx.stroke() 299 ctx.stroke()
@@ -313,6 +314,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -313,6 +314,7 @@ class CLUTRaycastingWidget(wx.Panel):
313 height -= self.padding 314 height -= self.padding
314 width -= self.padding 315 width -= self.padding
315 316
  317 + self._draw_histogram(ctx)
316 self._draw_gradient(ctx, height) 318 self._draw_gradient(ctx, height)
317 self._draw_curves(ctx) 319 self._draw_curves(ctx)
318 self._draw_points(ctx) 320 self._draw_points(ctx)
@@ -326,17 +328,17 @@ class CLUTRaycastingWidget(wx.Panel): @@ -326,17 +328,17 @@ class CLUTRaycastingWidget(wx.Panel):
326 width -= self.padding 328 width -= self.padding
327 height -= self.padding 329 height -= self.padding
328 y_init = 0 330 y_init = 0
329 - y_end = max(self.histogram_array[0]) 331 + y_end = max(self.histogram_array)
  332 + print y_end
330 proportion_x = width * 1.0 / (self.end - self.init) 333 proportion_x = width * 1.0 / (self.end - self.init)
331 proportion_y = height * 1.0 / (y_end - y_init) 334 proportion_y = height * 1.0 / (y_end - y_init)
332 print ":) ", y_end, proportion_y 335 print ":) ", y_end, proportion_y
333 self.histogram_pixel_points = [] 336 self.histogram_pixel_points = []
334 - for i in xrange(len(self.histogram_array[0])):  
335 - x = self.histogram_array[1][i]  
336 - y = self.histogram_array[0][i]  
337 - print x, y 337 + for i in xrange(len(self.histogram_array)):
  338 + y = self.histogram_array[i]
  339 + x = self.init+ i
338 x = (x + abs(self.init)) * proportion_x 340 x = (x + abs(self.init)) * proportion_x
339 - y = height - (y + abs(y_init)) * proportion_y 341 + y = height - y * proportion_y
340 self.histogram_pixel_points.append((x, y)) 342 self.histogram_pixel_points.append((x, y))
341 343
342 344
@@ -344,7 +346,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -344,7 +346,7 @@ class CLUTRaycastingWidget(wx.Panel):
344 self.pixels_points = [] 346 self.pixels_points = []
345 for curve in self.points: 347 for curve in self.points:
346 self.pixels_points.append([self.HounsfieldToPixel(i) for i in curve]) 348 self.pixels_points.append([self.HounsfieldToPixel(i) for i in curve])
347 - #self._build_histogram() 349 + self._build_histogram()
348 350
349 def HounsfieldToPixel(self, h_pt): 351 def HounsfieldToPixel(self, h_pt):
350 """ 352 """