Last active
March 4, 2022 15:23
-
-
Save jcreinhold/7a0a1f6bd14fb83740aa9eb419394515 to your computer and use it in GitHub Desktop.
Testing if two images are the same
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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