@@ -275,7 +275,7 @@ def set_image_volume_sample_distance(self, distance: float):
275275 def set_image_volume_scattering_blend (self , scattering_blend : float ):
276276 self .queue_request ('setImageVolumeScatteringBlend' , scattering_blend )
277277
278- def compare_images (self , fixed_image : Union [str , Image ], moving_image : Union [str , Image ], method : str = ' checkerboard' , pattern : Tuple [int , int , int ] = [ 4 , 4 , 4 ] , swap_image_order : bool = False ):
278+ def compare_images (self , fixed_image : Union [str , Image ], moving_image : Union [str , Image ], method : str = None , image_mix : float = None , checkerboard : bool = None , pattern : Union [ Tuple [int , int ], Tuple [ int , int , int ]] = None , swap_image_order : bool = None ):
279279 # image args may be image name or image object
280280 fixed_name = 'Fixed'
281281 if isinstance (fixed_image , str ):
@@ -287,7 +287,18 @@ def compare_images(self, fixed_image: Union[str, Image], moving_image: Union[str
287287 moving_name = moving_image
288288 else :
289289 self .set_image (moving_image , moving_name )
290- options = { 'method' : method , 'pattern' : pattern , 'swapImageOrder' : swap_image_order }
290+ options = {}
291+ # if None let viewer use defaults or last value.
292+ if method is not None :
293+ options ['method' ] = method
294+ if image_mix is not None :
295+ options ['imageMix' ] = image_mix
296+ if checkerboard is not None :
297+ options ['checkerboard' ] = checkerboard
298+ if pattern is not None :
299+ options ['pattern' ] = pattern
300+ if swap_image_order is not None :
301+ options ['swapImageOrder' ] = swap_image_order
291302 self .queue_request ('compareImages' , fixed_name , moving_name , options )
292303
293304 def set_label_image (self , label_image : Image ):
@@ -467,10 +478,44 @@ def view(data=None, **kwargs):
467478
468479 return viewer
469480
481+ def compare_images (fixed_image : Union [str , Image ], moving_image : Union [str , Image ], method : str = None , image_mix : float = None , checkerboard : bool = None , pattern : Union [Tuple [int , int ], Tuple [int , int , int ]] = None , swap_image_order : bool = None ):
482+ """Fuse 2 images with a checkerboard filter or as a 2 component image.
470483
471- def compare_images (* args , ** kwargs ):
472- """Fuse 2 images with a checkerboard filter"""
484+ The moving image is re-sampled to the fixed image space. Set a keyword argument to None to use defaults based on method.
485+
486+ Parameters
487+ ----------
488+ fixed_image: array_like, itk.Image, or vtk.vtkImageData
489+ Static image the moving image is re-sampled to. For 'blend and 'cyan-magenta' methods, the fixed image is on the first component.
490+
491+ moving_image: array_like, itk.Image, or vtk.vtkImageData
492+ Image is re-sampled to the fixed_image. For 'blend and 'cyan-magenta' methods, the moving image is on the second component.
493+
494+ method: string, default: None, possible values: 'cyan-magenta', 'blend', 'checkerboard', 'disabled'
495+ The checkerboard method picks pixels from the fixed and moving image to create a
496+ checkerboard pattern. Setting the method to checkerboard turns on the checkerboard flag.
497+ The blend and cyan-magenta method puts the fixed image on component 0, moving image on component 1.
498+ The cyan-magenta method also changes the color map for fixed image to cyan, moving image to magenta.
499+
500+ image_mix: float, default: None
501+ Changes the percent contribution the fixed vs moving image makes to the
502+ render by modifying the opacity transfer function. Value of 1 means max opacity for
503+ moving image, 0 for fixed image. If value is None and the method is "blend" or "cyan-magenta",
504+ the image_mix is set to 0.5. If the method is "checkerboard", the image_mix is set to 0.
505+
506+ checkerboard: bool, default: None
507+ Forces the checkerboard mixing of fixed and moving images for the cyan-magenta and blend methods.
508+ The rendered image has 2 components, each component reverses which image is sampled for each
509+ checkerboard box.
510+
511+ pattern: Union[Tuple[int, int], Tuple[int, int, int]], default: None
512+ The number of checkerboard boxes for each dimension.
513+
514+ swap_image_order: bool, default: None
515+ Reverses which image is sampled for each checkerboard box. This simply toggles
516+ image_mix between 0 and 1.
517+ """
473518 viewer = view ()
474- viewer .compare_images (* args , ** kwargs )
519+ viewer .compare_images (fixed_image = fixed_image , moving_image = moving_image , method = method , image_mix = image_mix , checkerboard = checkerboard , pattern = pattern , swap_image_order = swap_image_order )
475520 return viewer
476521
0 commit comments