Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add masked/bspline fitting variant of Nyul histogram matching. #607

Merged
merged 1 commit into from
Apr 13, 2024

Conversation

ntustison
Copy link
Member

Example. Be sure to compare the actual source and transformed source images.

import ants
from matplotlib import pyplot

source_image = ants.image_read(ants.get_ants_data("r16"))
source_mask = ants.get_mask(source_image)

reference_image = ants.image_read(ants.get_ants_data("r64"))
reference_mask = ants.get_mask(reference_image)

tx_source_image = ants.histogram_match_image2(source_image, reference_image, 
                                              source_mask, reference_mask,
                                              match_points=64,
                                              transform_domain_size=255)

# ants.image_write(tx_source_image, "tx_r16.nii.gz")

x = source_image[source_mask != 0].flatten()
y = reference_image[reference_mask != 0].flatten()
tx = tx_source_image[source_mask != 0].flatten()

pyplot.hist([x, y, tx], 64, alpha=0.5, label=["Source", "Ref", "Tx"])
pyplot.legend(loc="upper right")
pyplot.show()

@coveralls
Copy link

Coverage Status

coverage: 55.252% (-0.3%) from 55.519%
when pulling d20897f on NyulBspline
into f79e9f3 on master.

@ntustison ntustison merged commit ae974fb into master Apr 13, 2024
2 checks passed
@ntustison ntustison deleted the NyulBspline branch April 13, 2024 00:41
@gdevenyi
Copy link

The addition of the splines for histogram matching is a nice touch!

@ntustison
Copy link
Member Author

Thanks. That particular ITK B-spline filter that I wrote is probably my favorite piece of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants