2
$\begingroup$

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?enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ Use Colorize[] along with an appropriate Blend[] function. $\endgroup$ Commented May 25, 2016 at 17:08
  • $\begingroup$ It worked! Thanks :) $\endgroup$
    – Alaa
    Commented May 25, 2016 at 17:19
  • 1
    $\begingroup$ Than, can you please write an answer to your own question? :) $\endgroup$ Commented May 25, 2016 at 17:20

1 Answer 1

3
$\begingroup$
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
  ] 

BW

Colorize[CFG, ColorFunction -> (Blend[{Blue, Black}, #] &)]

color

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.