Negation after mask operation

I have loaded a CBCT into sitk::Image. And I ran:

sitk::Image imgTemp(imgOrg);
sitk::Image threshold = sitk::BinaryThreshold(imgTemp, 2000, 3600);  // let only teeth (tough bones)
sitk::MaskImageFilter mask;

and I see the teeth only (or tough bones):

	imgOut = mask.Execute(imgTemp, threshold);

Now I intend to let everything but teeth. For that, I tried:

sitk::Image imgMask = mask.Execute(imgTemp, threshold);
imgOut = sitk::NotEqual(imgTemp, imgMask);

I see only a diffuse cube, Then I tried

sitk::Image imgMask = mask.Execute(imgTemp, threshold);
imgOut = sitk::Not(imgMask);

The same diffuse cube. What filter should I choose in order to let everything but teeth from CBCT ? I appreciate any hint/help !

Regards,
Flaviu.

The filter you are looking for is MaskNegatedImageFilter:

sitk::sitk.MaskNegated(imgTemp, threshold)

Thank you. I have tried:

sitk::MaskNegatedImageFilter mask;
sitk::Image imgMask = mask.Execute(imgTemp, threshold);

I got:

sitk::ERROR: Failure to convert SimpleITK image of dimension: 3 and pixel type: "8-bit unsigned integer" to ITK image of dimension: 3 and pixel type: "16-bit signed integer"!

Also, I’ve tried:

sitk::MaskNegatedImageFilter mask;
sitk::Image imgMask = mask.Execute(imgTemp, sitk::Cast(threshold, imgTemp.GetPixelID()));

with the same error. Seem to be conversion error ? Or what ?

You diffuse cube might be all right. The values in that image are only 1’s and 0’s. When put in a volume renderer, it might not display well. You could try multiplying the values by 255 to get intensities better suited for volume rendering.

Thank you Dave, I’ve learned something here !