Message Boards Message Boards

Colorizing tomography images

Hi there I would like to share a color tomography I was able to obtain using Wolfram, even though the image looks Ok, it is far from what I wanted to make, the image comes out of a long program in which I am not able to change the relation of the numbers that represent the pixels, as I thought I could do on Mathematica. If there is a later advancement on being able to manipulate the pixel values let me know. I would be happy to place the lines of the program, but it is too long, but it does have medical applications for those acquainted with medical images:

LUNGS AND HEART TOMOGRAPHY

5 Replies

the image comes out of a long program in which I am not able to change the relation of the numbers that represent the pixels ...

It is somewhat hard to understand what it is you cannot do here with Mathematica. You just need to define a relation between pixel value and color. An even more simple approach might be this:

img = Import["https://cdn.drg.de/media/image/21865/100p/Abb-3-CT-Abdomen-copy-Universitaetsklinikum-Tuebingen.jpg"];
Colorize[img, ImageSize -> ImageDimensions[img], ColorFunction -> #] & /@ ColorData["Gradients"][[;; ;; 3]]

Does that help? Regards -- Henrik

POSTED BY: Henrik Schachner

Could you please add more details about why it is "far from what i wanted to make" and what you are looking for exactly. A minimal example pinpointing the issue is needed. If the notebook is too long you can add it to the post as a file attachment.

POSTED BY: Sam Carrettie

Hi Sam. Thank you for your interest as soon as I get back to the computer I will do what you told me. Regards.

p12=Image[]
p1=Colorize[p12,ColorRules->{j->Yellow,.1*j->LightYellow , .01*j ->Purple ,.001*j-> LightPurple ,k->Blue,.001*K-> LightBlue ,.03*K-> Black ,ComplexInfinity->White}]
p2=ImageData[%]
Image[v]
HistogramTransform==v
u=ImageDimensions[p1]
t=Reverse[u]
o1=ImageLevels[p1]
p=Flatten [p2]
ImageHistogram[p1]
ImageHistogram [p12]
n=p*(p-Power[p, (p)^-1])
l=p-p*Power[p, (p)^-1]
k=n/l
j=(n/l)^p

bg=Binarize[o1, f]

Module f= PixelValue=j->Yellow=j->Yellow=j->Blue=k->Blue->{p1,j}
ReplacePixelValue[p1,{j,p1}]
f=Module{u}->Yellow==20>j>1->j->{j;p1}==Yellow=Yellow=j
Column[ColorConvert[j,v]&/@{"Green"}]
ImageApply[UnitStep[f]&,bg]
SetAlphaChannel[f,p1]
ImageHistogram [p1]
ImageTransformation[p1,{f}&,DataRange->{{All}}]
ImageHistogram [v]
Do [NestWhile .1 * 10^-7<j<20 [HistogramTransform[p1]]]
v=HistogramTransform[p1]
c=ImageSubtract[v,p1]
d=Colorize[c,ColorRules->{j->Yellow,k->Blue}]
c3=HistogramTransform[c]
c2=ImageSubtract[d,c]
g=Image[p1]
ColorSeparate[g,"Red"]
z=ImageSubtract[ImageSubtract[#1]& @@ ColorSeparate[g,"Blue"]]
v1=ImageSubtract[g,z]
ImageSubtract[p1,v1]
b=ImageFilter[MedianDeviation[Flatten[#]]&,c2,2]// ImageAdjust
z1=ImageSubtract[ImageSubtract[#1]& @@ ColorSeparate[c2,"Blue"]]
b1=Colorize[z1,ColorRules->{z1->Pink,ComplexInfinity->White}]
ImageMultiply[c2,c3]
img=HistogramTransform[%]
DominantColors[%]
ImageMultiply[v,c,d,c2,g,z,c3]
HistogramTransform[%]
p21=ImageData[img]
p13=Image[v5]
DominantColors[%]
HistogramTransform==v5
u1=ImageDimensions[p21]
t1=Reverse[u1]
o12=ImageLevels[p21]
pr=Flatten [p21]
ImageHistogram[p13]
ImageHistogram [img]
n1=pr*(pr-Power[pr, (pr)^-1])
l1=pr-pr*Power[pr, (pr)^-1]
k1=n1/l1
j1=(n1/l1)^pr

bg1=Binarize[o12, f1]

Module f1= PixelValue=j1->Yellow=j1->Yellow=j1->Blue=k1->Blue->{img,j1}
ReplacePixelValue[img,{j1,img}]
f1=Module{u1}->Yellow==20>j1>1->j1->{j1;img}==Yellow=Yellow=j1
Column[ColorConvert[j1,v5]&/@{"Green"}]
ImageApply[UnitStep[f1]&,bg1]
SetAlphaChannel[f1,img]
ImageHistogram [img]
ImageTransformation[img,{f1}&,DataRange->{{All}}]
ImageHistogram [v5]
Do [NestWhile .1 * 10^-7<j1<20 [HistogramTransform[img]]]
v5=HistogramTransform[img]
d1=ImageSubtract[z,c3]
ImageSubtract[d,d1]
c1=HistogramTransform[%]
c3=ImageSubtract[c,c1]
c4=ImageMultiply[d1,c3]

g=ImageSubtract[v,c,d,c2,g,z,c3]
g1=ImageAdd[v,c,d,c2,g,z,c3]
ImageMultiply[g,g1]
a=HistogramTransform[%]
ImageSubtract[a,b]
ImageMultiply[a,b]
HistogramTransform[%]
F=ImageAdd[c1,c4]
DominantColors[%]
ImageAdd[c1,v]
DominantColors[%]
F1=HistogramTransform[F]
ImageAdd[F1,F]
ImageSubtract[F1,F]
f2=ImageSubtract[F,F1]
ct1=ImageCompose[F,F1]
f3=ImageAdd
p14=Image[p12]

p24=ImageData[%]
Image[v]
HistogramTransform==v4
u4=ImageDimensions[p14]
t4=Reverse[u4]
o14=ImageLevels[p14]
p4=Flatten [p24]
ImageHistogram[p14]
ImageHistogram [p12]
n4=p4*(p4-Power[p4, (p4)^-1])
l4=p4-p4*Power[p4, (p4)^-1]
k=n4/l
j=(n4/l4)^p4

bg4=Binarize[o14, f4]

Module f4= PixelValue=j4->Yellow=j4->Yellow=j4->Blue=k4->Blue->{p14,j4}
ReplacePixelValue[p14,{j4,p14}]
f4=Module{u4}->Yellow==20>j4>1->j4->{j4;p14}==Yellow=Yellow=j4
Column[ColorConvert[j4,v]&/@{"Green"}]
ImageApply[UnitStep[f4]&,bg4]
SetAlphaChannel[f4,p14]
ImageHistogram [p14]
ImageTransformation[p14,{f4}&,DataRange->{{All}}]
ImageHistogram [v4]
Do [NestWhile .1 * 10^-7<j4<20 [HistogramTransform[p14]]]
v4=HistogramTransform[p14]
c4=ImageSubtract[v,p14]
d4=Colorize[c4,ColorRules->{j4->Yellow,k4->Blue}]
c34=HistogramTransform[c4]
c24=ImageSubtract[d4,c4]
g4=Image[p14]
ColorSeparate[g4,"Red"]
z4=ImageSubtract[ImageSubtract[#1]& @@ ColorSeparate[g4,"Blue"]]
v14=ImageSubtract[g4,z4]
ImageSubtract[p14,v14]
b4=ImageFilter[MedianDeviation[Flatten[#]]&,c24,2]// ImageAdjust
z14=ImageSubtract[ImageSubtract[#1]& @@ ColorSeparate[c24,"Blue"]]
b14=Colorize[z14,ColorRules->{z14->Pink,ComplexInfinity->White}]
ImageMultiply[c24,c34]
img4=HistogramTransform[%]
DominantColors[%]
ImageMultiply[v4,c4,d4,c24,g4,z4,c34]
HistogramTransform[%]
p214=ImageData[img4]
p134=Image[v54]
DominantColors[%]
HistogramTransform==v54
u14=ImageDimensions[p21]
t14=Reverse[u14]
o124=ImageLevels[p214]
pr4=Flatten [p214]
ImageHistogram[p134]
ImageHistogram [img4]
n14=pr4*(pr4-Power[pr4, (pr4)^-1])
l14=pr4-pr4*Power[pr4, (pr4)^-1]
k14=n14/l14
j14=(n14/l14)^pr4

bg14=Binarize[o124, f14]

Module f14= PixelValue=j14->Yellow=j14->Yellow=j14->Blue=k14->Blue->{img4,j14}
ReplacePixelValue[img,{j14,img4}]
f14=Module{u14}->Yellow==20>j14>1->j1->{j14;img4}==Yellow=Yellow=j14
Column[ColorConvert[j14,v5]&/@{"Green"}]
ImageApply[UnitStep[f14]&,bg14]
SetAlphaChannel[f14,img4]
ImageHistogram [img4]
ImageTransformation[img4,{f14}&,DataRange->{{All}}]
ImageHistogram [v5]
Do [NestWhile .1 * 10^-7<j14<20 [HistogramTransform[img4]]]
v5=HistogramTransform[img]
d14=ImageSubtract[z4,c34]
ImageSubtract[d4,d14]
c14=HistogramTransform[%]
c34=ImageSubtract[c4,c14]
c44=ImageMultiply[d14,c34]

g4=ImageSubtract[v4,c4,d4,c24,g4,z4,c34]
g14=ImageAdd[v4,c4,d4,c24,g4,z4,c34]
ImageMultiply[g4,g14]
HistogramTransform[%]
ImageSubtract[a4,b4]
ImageMultiply[a4,b4]
HistogramTransform[%]
F24=ImageAdd[c14,c44]
DominantColors[%]
F4=ImageAdd[c14,v4]
DominantColors[%]
F34=HistogramTransform[F24]
ImageAdd[F14,F4]
ImageSubtract[F34,F24]
f3=ImageSubtract[F34,F24]
ct2=ImageCompose[F34,F24]
ImageCompose[ct1,ct2]
DominantColors[%]

Hi there, I posted the lines of the program, but the lines 12 to 14 are the numbers manipulation I want to make, but I think the computer is not taking it in consideration to change the values of the pixels accordingly, and that is what I wanted to investigate if there can be an image out of those imaginary relations. This is the picture that comes out of a mammographyenter image description here

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract