2 using System.Windows.Media.Imaging;
\r
6 public static class Figures
\r
9 public static void drawGrating(ref Image img, int width, int height, double wavelength, double contrast, double orientation, double phase)
\r
11 double width_half = width / 2.0, height_half = height / 2.0;
\r
12 if (img==null || img.width != width || img.height != height)
\r
13 img = new Image(width, height);
\r
14 double freq = 2 * Math.PI / wavelength;
\r
16 (x, y) => new Color(.5 +.5 * Math.sin(phase + (Math.sin(orientation)*x-Math.cos(orientation)*y) * freq))
\r
19 public static void drawGaussian(ref Image img, double sigma, double factor)
\r
21 int width = (int)(sigma * 8), height = (int)(sigma * 8);
\r
22 double width_half = width / 2.0, height_half = height / 2.0;
\r
23 if (img == null || img.width != width || img.height != height)
\r
24 img = new Image(width, height);
\r
26 (x, y) => new Color(factor * Math.gaussian(Math.radius(x - width_half, y - height_half), width / 8.0))
\r
30 public static void drawGabor(ref Image img, double sigma, double wavelength, double contrast, double orientation, double phase)
\r
32 int width = (int)(sigma * 8), height = (int)(sigma * 8);
\r
33 double width_half = width / 2.0, height_half = height / 2.0;
\r
34 if (img==null || img.width != width || img.height != height)
\r
35 img = new Image(width, height);
\r
36 double freq = 2 * Math.PI / wavelength;
\r
38 (x, y) => new Color(.5 + Math.gaussian(Math.radius(x - width_half, y - height_half), width / 8.0) * .5 * Math.sin(phase + (Math.sin(orientation)*x-Math.cos(orientation)*y) * freq))
\r