Xingorno / Speckle-Reducing-Anisotropic-Diffusion-SRAD

Speckle Reducing Anisotropic Diffusion (SRAD) Algorithm
18 stars 2 forks source link

needs a 3d implementation ;) #2

Open cyborgdennett opened 6 months ago

cyborgdennett commented 6 months ago

Input: image

Output: image I used your filter with small altercation, where every x y and z axis gets filtered

f = 'noisyMouse.nii'
nii = nib.load(f)
imgs = nii.get_fdata()

for _ in range(0,3):
    for i in range(0,imgs.shape[2]):
        imgs = np.moveaxis(imgs, 0, 2) # do every side
        img = imgs[:,:,i]
        img = 255*img # normalize to u8
        img = img.astype(np.uint8)
        iterationMaxStep, timeSize, decayFactor = 200/3,.05/3,1/3
        img = SRAD(img, iterationMaxStep, timeSize, decayFactor)
        imgs[:,:,i] = img/255

clipped_img = nib.Nifti1Image(imgs, nii.affine, nii.header)
nib.save(clipped_img, "denoisedMouse.nii")

Do you know how to make this filter for 3d?

cyborgdennett commented 6 months ago

Sorry My bad, i put the moveaxis in the wrong for loop

for _ in range(0,3):
    # should be here ;)
    imgs = np.moveaxis(imgs, 0, 2) # do every side
    for i in range(0,imgs.shape[2]):

This is my output now with the filter image