SuperElastix / SimpleElastix

Multi-lingual medical image registration library
http://simpleelastix.github.io
Apache License 2.0
506 stars 149 forks source link

Strange pixels as noise added post-registration #388

Open markbuckup opened 3 years ago

markbuckup commented 3 years ago

Hello,

When performing an affine or bspline on my image, strange, dark pixels appear throughout the image. I initially thought this made sense for bspline, as space is being warped and x,y coordinates are left without original RGB values, but I'm also seeing it for the affine?

Is there a way to prevent this? Or is there a way to collect the indices of these pixels so I can account for them myself?

Thanks!

mark

Screen Shot 2020-08-13 at 16 32 46
sorenchr2011 commented 3 years ago

Hi, If this is RGB images and you are using bspline interpolation for the final resampling then you can get values outside of the valid range (do you could have pixels with value 256 there even if input max was 255). Is your image output type float? What is the range of the transformed image? Soren

On Thu, Aug 13, 2020, 22:36 markbuckup notifications@github.com wrote:

Hello,

When performing an affine or bspline on my image, strange, dark pixels appear throughout the image. I initially thought this made sense for bspline, as space is being warped and x,y coordinates are left without original RGB values, but I'm also seeing it for the affine?

Is there a way to prevent this? Or is there a way to collect the indices of these pixels so I can account for them myself?

Thanks!

mark [image: Screen Shot 2020-08-13 at 16 32 46] https://user-images.githubusercontent.com/56090031/90184406-0efae780-dd83-11ea-85d3-2081ebc11aaa.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SuperElastix/SimpleElastix/issues/388, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHBDDLU2BHNR6H3IICQOP3SARFFTANCNFSM4P62MLHA .

mynschen commented 3 years ago

@markbuckup thanks for asking. I'm facing a similar problem @sorenchr2011 thanks for pointing this out. Any simple solution to this issue you would recommend? I've tried some other interpolation methods but the noises persisted. In my case, I have greyscale image as moving image while color image as fixed image. Looking forward to any comment. Thanks =)

mynschen commented 3 years ago

I figured out that my pixel noises were generated using np.uint8(), which takes 0.0 as 255 (np.uint8(0.0)=255). A simple solution to this issue: rI = sitk.GetArrayFromImage(resultImage) rI = rI*(rI>0) + (rI<=0) Then np.uint8(rI) will be noise-free.

heyblackC commented 2 years ago

a more simple solution: resultImage = sitk.Threshold(resultImage, 0.0001, 1e9, 0.00001) this line can force 0.0 to become a number which is > 0.0, and it works in my computer. @mynschen ,you are right!