How to combine multiple Binary Label Images to form one grayscale image?

Hello,

I have four binary label images representing four types of tissues in a tumor within the brain. I want to combine these four images into one image, and give different intensity values to each tissue. The goal is to view the whole tumor with four tissues demarcated. How can I do this?

Hello @debapriya,
Assuming the labels do not overlap:

import SimpleITK as sitk

label1 = sitk.Image([128, 128], sitk.sitkUInt8)
label1[10:30, 10:30] = 1

label2 = sitk.Image([128, 128], sitk.sitkUInt8)
label2[50:70, 50:70] = 1

label3 = sitk.Image([128, 128], sitk.sitkUInt8)
label3[100:120, 100:120] = 1

label1_value = 1
label2_value = 2
label3_value = 3

combined_non_overlapping_labels = (
    label1 * label1_value + label2 * label2_value + label3 * label3_value
)
3 Likes

Ohh, wow I agree :point_right: @zivy.

The method you suggest is really great and easy to implement.

You can try this: combine multiple binary images into one color image - Mathematica Stack Exchange

Thank you @zivy . It worked.