debapriya
(Debapriya Sengupta)
June 11, 2024, 3:12pm
1
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?
zivy
(Ziv Yaniv)
June 11, 2024, 3:56pm
2
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
Kelvin
(Kelvin)
June 14, 2024, 7:35am
3
Ohh, wow I agree @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
debapriya
(Debapriya Sengupta)
June 15, 2024, 10:53am
4
Thank you @zivy . It worked.