Commit d996d5828e6aa367f6f91ab3c28a3a855c8f3612
1 parent
3e51ce95
Exists in
master
and in
68 other branches
ADD: Pseudo colors
Showing
1 changed file
with
20 additions
and
3 deletions
Show diff stats
invesalius/data/slice_.py
| @@ -55,6 +55,9 @@ class Slice(object): | @@ -55,6 +55,9 @@ class Slice(object): | ||
| 55 | 55 | ||
| 56 | ps.Publisher().subscribe(self.UpdateWindowLevelBackground,\ | 56 | ps.Publisher().subscribe(self.UpdateWindowLevelBackground,\ |
| 57 | 'Bright and contrast adjustment image') | 57 | 'Bright and contrast adjustment image') |
| 58 | + | ||
| 59 | + ps.Publisher().subscribe(self.UpdateColorTableBackground,\ | ||
| 60 | + 'Change color table from background image') | ||
| 58 | 61 | ||
| 59 | def __set_current_mask_threshold_limits(self, pubsub_evt): | 62 | def __set_current_mask_threshold_limits(self, pubsub_evt): |
| 60 | thresh_min = pubsub_evt.data[0] | 63 | thresh_min = pubsub_evt.data[0] |
| @@ -395,12 +398,13 @@ class Slice(object): | @@ -395,12 +398,13 @@ class Slice(object): | ||
| 395 | return img_colours_bg.GetOutput() | 398 | return img_colours_bg.GetOutput() |
| 396 | 399 | ||
| 397 | def UpdateWindowLevelBackground(self, pubsub_evt): | 400 | def UpdateWindowLevelBackground(self, pubsub_evt): |
| 401 | + | ||
| 398 | window, level = pubsub_evt.data | 402 | window, level = pubsub_evt.data |
| 399 | window_level = self.window_level | 403 | window_level = self.window_level |
| 400 | - | 404 | + |
| 401 | if not((window == window_level.GetWindow()) and\ | 405 | if not((window == window_level.GetWindow()) and\ |
| 402 | (level == window_level.GetLevel())): | 406 | (level == window_level.GetLevel())): |
| 403 | - | 407 | + |
| 404 | window_level.SetWindow(window) | 408 | window_level.SetWindow(window) |
| 405 | window_level.SetLevel(level) | 409 | window_level.SetLevel(level) |
| 406 | window_level.SetOutputFormatToLuminance() | 410 | window_level.SetOutputFormatToLuminance() |
| @@ -410,7 +414,20 @@ class Slice(object): | @@ -410,7 +414,20 @@ class Slice(object): | ||
| 410 | self.lut_bg.SetTableRange(thresh_min, thresh_max) | 414 | self.lut_bg.SetTableRange(thresh_min, thresh_max) |
| 411 | self.img_colours_bg.SetInput(window_level.GetOutput()) | 415 | self.img_colours_bg.SetInput(window_level.GetOutput()) |
| 412 | 416 | ||
| 413 | - | 417 | + def UpdateColorTableBackground(self, pubsub_evt): |
| 418 | + values = pubsub_evt.data | ||
| 419 | + | ||
| 420 | + if (values[0]): | ||
| 421 | + self.lut_bg.SetNumberOfColors(values[0]) | ||
| 422 | + | ||
| 423 | + self.lut_bg.SetSaturationRange(values[1]) | ||
| 424 | + self.lut_bg.SetHueRange(values[2]) | ||
| 425 | + self.lut_bg.SetValueRange(values[3]) | ||
| 426 | + | ||
| 427 | + thresh_min, thresh_max = self.window_level.GetOutput().GetScalarRange() | ||
| 428 | + self.lut_bg.SetTableRange(thresh_min, thresh_max) | ||
| 429 | + | ||
| 430 | + | ||
| 414 | def CreateMask(self, imagedata=None, name=None): | 431 | def CreateMask(self, imagedata=None, name=None): |
| 415 | 432 | ||
| 416 | future_mask = Mask() | 433 | future_mask = Mask() |