def make_compare_images(image, reference_file, tolerance=0.1): reader = imagereader.vmtkImageReader() try: datadir = os.path.join( os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'vmtk-test-data', 'imagereference') if not os.path.isdir(datadir): raise ValueError() except ValueError: datadir = os.path.join( os.path.dirname( os.path.dirname( os.path.dirname( os.path.dirname(os.path.realpath(__file__))))), 'vmtk-test-data', 'imagereference') if not os.path.isdir(datadir): raise ValueError( 'the vmtk-test-data repository cannot be found at the same level as vmtk. expected it to be at', datadir) reader.InputFileName = os.path.join(datadir, reference_file) reader.Execute() comp = imagecompare.vmtkImageCompare() comp.Image = image comp.ReferenceImage = reader.Image comp.Method = 'subtraction' comp.Tolerance = tolerance comp.Execute() return comp.Result
def make_compare_images(image, reference_file, tolerance=0.1): reader = imagereader.vmtkImageReader() try: datadir = os.path.join( os.path.dirname( os.path.dirname( os.path.realpath(__file__))), 'vmtk-test-data', 'imagereference') if not os.path.isdir(datadir): raise ValueError() except ValueError: datadir = os.path.join( os.path.dirname( os.path.dirname( os.path.dirname( os.path.dirname( os.path.realpath(__file__))))), 'vmtk-test-data', 'imagereference') if not os.path.isdir(datadir): raise ValueError('the vmtk-test-data repository cannot be found at the same level as vmtk. expected it to be at', datadir) reader.InputFileName = os.path.join(datadir, reference_file) reader.Execute() comp = imagecompare.vmtkImageCompare() comp.Image = image comp.ReferenceImage = reader.Image comp.Method = 'subtraction' comp.Tolerance = tolerance comp.Execute() return comp.Result
def test_compare_same_image(aorta_image): comparer = comp.vmtkImageCompare() comparer.Method = 'subtraction' comparer.Image = aorta_image comparer.ReferenceImage = aorta_image comparer.Execute() assert comparer.Result is True
def test_compare_not_same_image(aorta_image): wraper = wrap.vmtkImageToNumpy() wraper.Image = aorta_image wraper.Execute() multiplied = wraper.ArrayDict multiplied['PointData']['ImageScalars'] = multiplied['PointData']['ImageScalars'] * 2 back = wrap2.vmtkNumpyToImage() back.ArrayDict = multiplied back.Execute() comparer = comp.vmtkImageCompare() comparer.Method = 'subtraction' comparer.Image = aorta_image comparer.ReferenceImage = back.Image comparer.Execute() assert comparer.Result is False