ANTsX / ANTsR

R interface to the ANTs biomedical image processing library
https://antsx.github.io/ANTsR
Apache License 2.0
127 stars 35 forks source link

ENH: histogram matching Nyul/bspline variant w/ masking. #398

Closed ntustison closed 3 months ago

ntustison commented 3 months ago

https://github.com/ANTsX/ANTsPy/pull/607


sourceImage <- antsImageRead( getANTsRData( "r16" ) )
referenceImage <- antsImageRead( getANTsRData( "r64" ) )
sourceMask <- getMask( sourceImage )
referenceMask <- getMask( referenceImage )
tx <- histogramMatchImage2( sourceImage, referenceImage, sourceMask, referenceMask )

# antsImageWrite( tx, "txR.nii.gz" )

sourceHist <- hist( sourceImage[sourceMask != 0] )
referenceHist <- hist( referenceImage[referenceMask != 0] )
txHist <- hist( tx[sourceMask != 0] ) 

plot( sourceHist, col = rgb( 1, 0, 0, 0.25 ) )
plot( referenceHist, col = rgb( 0, 1, 0, 0.25 ), add = TRUE )
plot( txHist, col = rgb( 0, 0, 1, 0.25 ), add = TRUE )