0

I am working with CT images and trying to remove the noise. Original image as follows:

enter image description here

I created a mask of the region I needed and my code is as follows:

def remove_noise(image): 
    segmentation = morphology.dilation(image, np.ones((1, 1, 1)))
    labels, label_nb = ndimage.label(segmentation)
    
    label_count = np.bincount(labels.ravel().astype(int))#
    label_count[0] = 0

    mask = labels == label_count.argmax()
 
    mask = morphology.dilation(mask, np.ones((1, 1, 1)))
    mask = ndimage.morphology.binary_fill_holes(mask)
    mask = morphology.dilation(mask, np.ones((1, 1, 1)))
    masked_image = mask * image
    return masked_image

enter image description here

Mask is a binary array with 0 & 1 values only, but the original image has intensities ranging from -1024 to 3071 (I don't want to normalize original image here). When I do: masked_image = mask * original_image this is what I get (looks like intensities have changed):

enter image description here

But, the image I need is as follows (without the lines under the CT scan):

enter image description here

What am I doing wrong here? Any help would be appreciated.

Dushi Fdz
  • 161
  • 3
  • 22
  • 1
    Intensities cannot change if you multiply by either 0 or 1. either they keep the same or get to 0. –  Jul 05 '22 at 15:11
  • Yeah, but you see the resulting image is different than the original image. – Dushi Fdz Jul 05 '22 at 15:28
  • 2
    To clarify, you are trying to leave the original CT unchanged other than removing the lines from the bed under the patient? Then you would want your mask to be 1 everywhere except where the bedlines are. – nigh_anxiety Jul 05 '22 at 15:54
  • That's right, that's what I wanted. I included my code for generating the mask in the question. Why when multiplied by the mask (binary), the original intensities have changed in the mask region? – Dushi Fdz Jul 05 '22 at 15:58

0 Answers0