I created fork grating on mathematica and it is gray tone image, I need to conver it into Black and Blue image instead. And I use the Image code to do that but it didn't work! is there another way to do that?
1 Answer
$\begingroup$
$\endgroup$
1
w = w0 (1 + z^2/zR^2);
w1 = 100 200*^-6;
w0set = 2*^-6;
λ0 = 632*^-9;
Ixy2 = FullSimplify[ComplexExpand[(.5 Exp[I (k x + Δϕ)] + .5 Exp[I l ArcTan[y, x]])*Conjugate[.5 Exp[I (k x + Δϕ)] + .5 Exp[I l ArcTan[y, x]]]]];
Grating0 = Ixy2 /. {k -> 11 2 π/λ 0/8, w0 -> w0set, zR -> π w0set^2/λ0, z -> 10*^-4, p -> 0, l -> 0, r -> Norm[{x, y}], Δϕ -> 0};
Grating1 = Ixy2 /. {k -> 11 2 π/λ 0/8, w0 -> w0set, zR -> π w0set^2/λ0, z -> 10*^-4, p -> 0, l -> 1, r -> Norm[{x, y}], Δϕ -> 0};
CFG = MatrixPlot[
Table[
Grating0 + Grating1,
{y, -w1/1000, w1/1000, w1/500000},
{x, -w1/1000, w1/1000, w1/500000}
],
ColorFunction -> "GrayTones",
Frame -> False, PlotRangePadding -> 0, ImageSize -> 768
]
Colorize[CFG, ColorFunction -> (Blend[{Blue, Black}, #] &)]
-
$\begingroup$ Hey Alaa, thank you for taking the time to self-answer! Take a look at these guides to see how you can better format your code for readability: How do I format my posts using Markdown or HTML? and How to copy code from Mathematica so it looks good on this site. Note also that you can always edit your own questions / answers by clicking on the "edit" link right underneath them. $\endgroup$– MarcoBCommented May 25, 2016 at 18:26
Colorize[]
along with an appropriateBlend[]
function. $\endgroup$