Skip to content

Instantly share code, notes, and snippets.

@jcreinhold
Last active March 4, 2022 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcreinhold/7a0a1f6bd14fb83740aa9eb419394515 to your computer and use it in GitHub Desktop.
Save jcreinhold/7a0a1f6bd14fb83740aa9eb419394515 to your computer and use it in GitHub Desktop.
Testing if two images are the same
# pymedio is used here because it opens a wide variety of
# medical image formats but you can use 'nibabel', 'pydicom',
# or 'SimpleITK' and extract the pixel data as an array and
# use the same functions to test equality
from pymedio.image import Image
# 'query_image' and 'target_image' can be most common medical
# image formats, e.g., NIfTI, directory of DICOM frames, etc.
query = Image.from_path("path/to/query_image")
target = Image.from_path("path/to/target_image")
# the answer to the image equality query is on the right side
# of the variable assignment expression
are_the_same = (query == target).all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment