Closed ntustison closed 2 months ago
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()
coverage: 55.252% (-0.3%) from 55.519% when pulling d20897f4ea8593ebe6c40335edccd0d6db1305a4 on NyulBspline into f79e9f3ac9cfde641c3089bc4df938a57cbad826 on master.
The addition of the splines for histogram matching is a nice touch!
Thanks. That particular ITK B-spline filter that I wrote is probably my favorite piece of code.
Example. Be sure to compare the actual source and transformed source images.