-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathProgram.cs
497 lines (384 loc) · 22.9 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
using Aardvark.Base;
using System;
using System.IO;
namespace PixImageDemo
{
public static class Program
{
public static void Main(string[] args)
{
Aardvark.Base.Aardvark.Init();
var dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "PixImageDemo");
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
var a = PixImage.Load(@"C:\Users\hs\Desktop\Debug\gah.jpg");
a.Save(@"C:\Users\hs\Desktop\PixImageDemo\urdar.jpg");
PolygonDemo(dir);
HowManyColorsIllusion(dir);
ResampleDemo(dir);
LinearRampDemo(dir);
VariousDemos(dir);
}
public static void PolygonDemo(string dir)
{
// This code produces tiny tiff images that demonstrate the pixel-
// level precision of SetMonotonePolygonFilledRaw.
var tris = new[] {
new { Tri = new V2d[] { new V2d(7.7, 2.5), new V2d(11.7, 2.5), new V2d(9.8, 0.8) }, Col = C3b.DarkGreen },
new { Tri = new V2d[] { new V2d(11.7, 2.5), new V2d(7.7, 2.5), new V2d(9.5, 5.2) }, Col = C3b.Green },
new { Tri = new V2d[] { new V2d(7, 4), new V2d(5, 6), new V2d(8, 7) }, Col = C3b.Green },
new { Tri = new V2d[] { new V2d(1, 1), new V2d(2, 4), new V2d(6, 2) }, Col = C3b.Green },
new { Tri = new V2d[] { new V2d(7, 4), new V2d(1, 6), new V2d(5, 6) }, Col = C3b.DarkGreen },
new { Tri = new V2d[] { new V2d(7, 4), new V2d(8, 7), new V2d(9.5, 5.5) }, Col = C3b.DarkGreen },
new { Tri = new V2d[] { new V2d(13.5, 5.5), new V2d(13.5, 7.5), new V2d(15.5, 5.5) }, Col = C3b.Green },
new { Tri = new V2d[] { new V2d(15.5, 5.5), new V2d(13.5, 7.5), new V2d(15.5, 7.5) }, Col = C3b.DarkGreen },
new { Tri = new V2d[] { new V2d(15, 0), new V2d(13.5, 1.5), new V2d(14.5, 2.5) }, Col = C3b.Green },
new { Tri = new V2d[] { new V2d(14.5, 2.5), new V2d(13.5, 1.5), new V2d(14.5, 2.5) }, Col = C3b.Red },
new { Tri = new V2d[] { new V2d(7.5, 0.5), new V2d(6.5, 1.5), new V2d(7.5, 1.5) }, Col = C3b.Red },
new { Tri = new V2d[] { new V2d(6.3, 0.3), new V2d(5.3, 1.3), new V2d(6.3, 1.3) }, Col = C3b.Red },
new { Tri = new V2d[] { new V2d(11.5, 4.5), new V2d(11.5, 6.5), new V2d(12.5, 5.5) }, Col = C3b.DarkGreen },
};
var triImg = new PixImage<byte>(16, 8, 3);
var tMat = triImg.GetMatrix<C3b>();
Report.BeginTimed("polygon demo triangles");
foreach (var t in tris)
tMat.SetMonotonePolygonFilledRaw(t.Tri, t.Col);
triImg.Save(Path.Combine(dir, "polygon-triangles.tiff"));
Report.End();
var polyImg = new PixImage<byte>(10, 10, 3);
var pMat = polyImg.GetMatrix<C3b>();
V2d[] poly = new V2d[] {
new V2d( 4, 1),
new V2d( 1, 3),
new V2d( 2, 6),
new V2d( 2.1, 6.1),
new V2d( 5, 7),
new V2d( 8, 5),
new V2d( 9, 3),
};
Report.BeginTimed("polygon demo polygon");
pMat.SetMonotonePolygonFilledRaw(poly, C3b.Red);
polyImg.Save(Path.Combine(dir, "polygon-polygon.tiff"));
Report.End();
}
/// <summary>
/// Creates Images of an optical illusion that tricks the mind into
/// seeing more different colors (4) than are actually present in the
/// image (3).
/// </summary>
public static PixImage<byte> CreateHowManyColorsIllusion(int size, bool parallel = true)
{
var scale = 1024.0 / size;
var delta = 0.5 * (double)(size - 1);
var pixImage = new PixImage<byte>(size, size, 3);
var colorMatrix = pixImage.GetMatrix<C3b>();
var orange = new C3b(255, 150, 0);
var magenta = new C3b(255, 0, 255);
var bluegreen = new C3b(0, 255, 150);
Func<long, long, C3b> pixelFun = (x, y) =>
{
var xd = scale * (x - delta); var yd = scale * (y - delta);
var r = Fun.Sqrt(xd * xd + yd * yd);
var phi = Fun.Atan2(yd, xd);
var lp1 = phi / Constant.PiTimesFour;
var lp2 = phi / Constant.Pi; // TimesTwo;
var lr = Fun.Log(r) / Constant.E;
var p1 = Fun.Frac(0.05 + 4 * (lr - lp1));
var p2 = Fun.Frac(96 * (lr + lp2)); // 64
return p2 < 0.5
? (p1 >= 0.0 && p1 < 0.25 ? bluegreen : orange)
: (p1 >= 0.5 && p1 < 0.75 ? bluegreen : magenta);
};
if (parallel)
colorMatrix.SetByCoordParallelY(pixelFun);
else
colorMatrix.SetByCoord(pixelFun);
return pixImage;
}
public static void HowManyColorsIllusion(string dir)
{
bool parallel = true;
var sizes = new[] { 512, 576, 648, 768, 864, 1024, 1152, 1296, 1536, 1728 };
Report.BeginTimed("how-many-colors illusions");
foreach (var size in sizes)
{
Report.BeginTimed("size: {0}", size);
var pixImg = CreateHowManyColorsIllusion(size, parallel);
pixImg.Save(Path.Combine(dir, "how-many-colors-" + size.ToString() + ".png"));
Report.End();
}
Report.End();
}
public static void SetScaledCubicFast(this Matrix<float, C3f> targetMat, Matrix<float, C3f> sourceMat,
Func<double, Tup4<float>> interpolator)
{
var dxa = new Tup4<long>[targetMat.SX];
var wxa = new Tup4<float>[targetMat.SX];
long fx = sourceMat.FX, ex = sourceMat.EX, dx1 = sourceMat.DX;
var scaleX = (double)sourceMat.SX / (double)targetMat.SX;
double x = 0.5 * scaleX - 0.5;
for (long tix = 0, tsx = targetMat.SX; tix < tsx; tix++, x += scaleX)
{
double xid = Fun.Floor(x); long xi = (long)xid; double xf = x - xid;
var dx = Tensor.Index4SamplesClamped(xi, fx, ex, dx1);
var dxi = xi * dx1; dx.E0 += dxi; dx.E1 += dxi; dx.E2 += dxi; dx.E3 += dxi;
dxa[tix] = dx; wxa[tix] = interpolator(xf);
}
var dya = new Tup4<long>[targetMat.SY];
var wya = new Tup4<float>[targetMat.SY];
long o = sourceMat.Origin, fy = sourceMat.FY, ey = sourceMat.EY, dy1 = sourceMat.DY;
var scaleY = (double)sourceMat.SY / (double)targetMat.SY;
double y = 0.5 * scaleY - 0.5;
for (long tiy = 0, tsy = targetMat.SY; tiy < tsy; tiy++, y += scaleY)
{
double yid = Fun.Floor(y); long yi = (long)yid; double yf = y - yid;
var dy = Tensor.Index4SamplesClamped(yi, fy, ey, dy1);
var dyi = o + yi * dy1; dy.E0 += dyi; dy.E1 += dyi; dy.E2 += dyi; dy.E3 += dyi;
dya[tiy] = dy; wya[tiy] = interpolator(yf);
}
targetMat.ForeachIndex((tix, tiy, i) =>
targetMat[i] = sourceMat.Sample16(dxa[tix], dya[tiy], wxa[tix], wya[tiy],
Col.LinCom, Col.LinCom));
}
/// <summary>
/// Perform image resampling in software. Shows how to use higher order
/// resampling (e.g. Lanczos or Bicubic) on matrices. This is not a very
/// fast implementation, but it works on Matrices of arbitrary type!
/// </summary>
public static void ResampleDemo(string dir)
{
Report.BeginTimed("resample example");
var inImg = CreateHowManyColorsIllusion(300);
var inMat = inImg.GetMatrix<C3b>();
// enlarge by a factor of Pi to see what happens
double scale = 1.0 / Constant.Pi;
double shift = -13.0;
var outImg0 = new PixImage<byte>(1024, 1024, 3);
var outMat0 = outImg0.GetMatrix<C3b>();
var outImg1 = new PixImage<byte>(1024, 1024, 3);
var outMat1 = outImg1.GetMatrix<C3b>();
var outImg2 = new PixImage<byte>(1024, 1024, 3);
var outMat2 = outImg2.GetMatrix<C3b>();
var outImg3 = new PixImage<byte>(1024, 1024, 3);
var outMat3 = outImg3.GetMatrix<C3b>();
// create the cubic weighting function. Parameter a=-0.5 results in the cubic Hermite spline.
var hermiteSpline = Fun.CreateCubicTup4f(-0.5);
outMat0.ForeachIndex((x, y, i) =>
{
/// Note: LinComRawF in x direction results in a byte color (range 0-255) stored
/// in a C3f. The second Col.LinCom for the y direction does not perform any additional
/// scaling, thus we need to map the "ByteInFloat" color back to a byte color at the
/// end (this perfoms clamping). Tensor.Tensor.Index6SamplesClamped clamps to the border
/// region and allows any double pixel address.
outMat0[i] = inMat.Sample36(x * scale + shift, y * scale + shift,
Fun.Lanczos3f, Fun.Lanczos3f,
Col.LinComRawF, Col.LinCom,
Tensor.Index6SamplesClamped, Tensor.Index6SamplesClamped)
.Map(Col.ByteInFloatToByteClamped);
/// Note: LinComRawF in x direction results in a byte color (range 0-255) stored
/// in a C3f. The second Col.LinCom for the y direction does not perform any additional
/// scaling, thus we need to map the "ByteInFloat" color back to a byte color at the
/// end (this perfoms clamping). Tensor.Index4SamplesClamped clamps to the border
/// region and allows any double pixel address.
outMat1[i] = inMat.Sample16(x * scale + shift, y * scale + shift,
hermiteSpline, hermiteSpline,
Col.LinComRawF, Col.LinCom,
Tensor.Index4SamplesClamped, Tensor.Index4SamplesClamped)
.Map(Col.ByteInFloatToByteClamped);
/// Note here the two Col.LinCom calls perform the clamping immediately. Thus we have
/// Five clamping calls on each sample: 4 on each x-line, and one in the final
/// y-interpolation.
/// Here we have cyclic border handling. Note that Tensor.Index4SamplesCyclic1 only
/// handles one cycle at each side (minus some border pixels), so the addressable
/// range is not quite 3x3 times the size of the original image.
outMat2[i] = inMat.Sample16(x * scale + shift, y * scale + shift,
hermiteSpline, hermiteSpline,
Col.LinCom, Col.LinCom,
Tensor.Index4SamplesCyclic1, Tensor.Index4SamplesCyclic1);
outMat3[i] = inMat.Sample4Clamped(x * scale + shift, y * scale + shift, Fun.Lerp, Fun.Lerp);
//.Map(Col.ByteFromByteInDoubleClamped);
});
outImg0.Save(Path.Combine(dir, "resample-36clamped.tif"));
outImg1.Save(Path.Combine(dir, "resample-16clamped.tif"));
outImg2.Save(Path.Combine(dir, "resample-d16cyclic.tif"));
outImg3.Save(Path.Combine(dir, "resample-4clamped.tif"));
Report.End();
}
public static void VariousDemos(string dir)
{
bool alternative = true;
// WriteLinearRampImage();
// Interpolation();
Report.BeginTimed("various PixImage demos");
// NOTE: in the following comments a byte image is an image that uses a
// byte for each channel of each pixel, a float image is an image that uses
// a float for each channel of each pixel.
var colorImage = CreateHowManyColorsIllusion(1024);
// scaling an image
var scaledColorImage = new PixImage<byte>(1280, 800, 3);
scaledColorImage.GetMatrix<C3b>().SetScaledCubic(colorImage.GetMatrix<C3b>());
scaledColorImage.Save(Path.Combine(dir, "v-scaled-image.png"));
// For shrinking images, interpoation of image values is not the optimal
// resampling filter. Here BSpline3 or BSpline5 approximation can be used
// which are 3rd order or 5th order approximations of a Gauss filter.
var shrunkColorImage = new PixImage<byte>(512, 512, 3);
shrunkColorImage.GetMatrix<C3b>().SetScaledBSpline5(colorImage.GetMatrix<C3b>());
shrunkColorImage.Save(Path.Combine(dir, "v-shrunk-image.png"));
var largeColorImage = new PixImage<byte>(4096, 4096, 3);
largeColorImage.GetMatrix<C3b>().SetScaledLanczos(colorImage.GetMatrix<C3b>());
largeColorImage.Save(Path.Combine(dir, "v-large-lanczos-image.png"));
var scaledColorImage2 = new PixImage<byte>(1280, 800, 3);
scaledColorImage2.GetMatrix<C3b>().SetScaledLanczos(colorImage.GetMatrix<C3b>());
scaledColorImage.Save(Path.Combine(dir, "v-scaled-lanczos-image.png"));
var smallColorImage = CreateHowManyColorsIllusion(256);
var nearestScaledImage = new PixImage<byte>(1024, 768, 3);
nearestScaledImage.GetMatrix<C3b>().SetScaledNearest(smallColorImage.GetMatrix<C3b>());
nearestScaledImage.Save(Path.Combine(dir, "v-scaled-nearest-image.png"));
// writing a color png image
colorImage.Save(Path.Combine(dir, "v-color-image.png"));
var grayImage = colorImage.ToGrayscalePixImage();
// scaling a grayscale image
var scaledGrayImage = new PixImage<byte>(1280, 800, 1);
scaledGrayImage.Matrix.SetScaledLanczos(grayImage.Matrix);
scaledGrayImage.Save(Path.Combine(dir, "v-scaled-gray-image.png"));
// for grayscale and black/white images the Matrix property works
grayImage.Matrix.SetLineY(16, 0, 100, 0);
// writing a grayscale png image
grayImage.Save(Path.Combine(dir, "v-gray-image.png"));
var gray2colorImage = grayImage.ToPixImage<byte>(Col.Format.BGR);
// writing grayxcal image as a color image
gray2colorImage.Save(Path.Combine(dir, "v-gray2color-image.png"));
// loading a 8-bit per channel color image
var byteImg = new PixImage<byte>(Path.Combine(dir, "v-color-image.png"));
//var byteImg2 = byteImg.Scaled(0.5);
//byteImg2.SaveAsImage(Path.Combine(dir, "v-color-2.png"));
//var byteImg4 = byteImg2.Scaled(0.5);
//byteImg4.SaveAsImage(Path.Combine(dir, "v-color-4.png"));
//var byteImg8 = byteImg4.Scaled(0.5);
//byteImg8.SaveAsImage(Path.Combine(dir, "r-color-8.png"));
// retrieving channel matrices from an rgb image
var rc = byteImg.GetChannel(Col.Channel.Red);
var gc = byteImg.GetChannel(Col.Channel.Green);
var bc = byteImg.GetChannel(Col.Channel.Blue);
// convert 8bit/channel rgb image to 16bit/channel image
// var ushortImage = byteImg.ToPixImage<ushort>();
// ushortImage.Rotated(30 * Constant.RadiansPerDegree, false)
// .SaveAsImage(Path.Combine(odir, "rotated_30_rgb16.png"));
// save 16bit/channel rgb image.
// ushortImage.SaveAsImage(Path.Combine(odir, "rgb8_to_rgb16.tif"));
// load 16bit/channel rgb image
// var ushortImage2 = new PixImage<ushort>(Path.Combine(odir, "rgb8_to_rgb16.tif"));
// save again as 8bit/channel rgb image
// ushortImage2.ToPixImage<byte>().SaveAsImage(Path.Combine(odir, "rgb8_to_rgb16_to_rgb8.tif"));
// building a new rgb image from channel matrices
var newImg = new PixImage<byte>(rc, gc, bc);
// writing an 8-bit per channel png image
newImg.Save(Path.Combine(dir, "v-recombined-color.png"), PixFileFormat.Png);
//byteImg.Rotated(60.0 * Constant.RadiansPerDegree)
// .SaveAsImage(Path.Combine(dir, "v-rotated-60-resized.png"));
//byteImg.Rotated(90.0 * Constant.RadiansPerDegree)
// .SaveAsImage(Path.Combine(dir, "v-rotated-90-resized.png"));
//byteImg.Volume.Transformed(ImageTrafo.Rot90).ToPixImage()
// .SaveAsImage(Path.Combine(odir, "rotated_90_csharp_rgb8.png"));
//byteImg.Rotated(180.0 * Constant.RadiansPerDegree)
// .SaveAsImage(Path.Combine(dir, "v-rotated-180-resized.png"));
//byteImg.Volume.Transformed(ImageTrafo.Rot180).ToPixImage()
// .SaveAsImage(Path.Combine(odir, "rotated_180_csharp_rgb8.png"));
//byteImg.Rotated(270.0 * Constant.RadiansPerDegree)
// .SaveAsImage(Path.Combine(dir, "v-rotated-270-resized.png"));
//byteImg.Volume.Transformed(ImageTrafo.Rot270).ToPixImage()
// .SaveAsImage(Path.Combine(odir, "rotated_270_csharp_rgb8.png"));
// loading an 8-bit per channel rgb image directly as a float image
var floatImg = new PixImage<float>(Path.Combine(dir, "v-color-image.png"));
// converting a float image to a byte image
var floatToByteImg = floatImg.ToPixImage<byte>();
// saving the converted image in png format
floatToByteImg.Save(Path.Combine(dir, "v-byte2float2byte-color.png"));
// color conversion to linear response
var linearFloatImg = floatImg.Copy<C3f>(Col.SRGBToLinearSRGB);
// converting the linear float image to a byte image and saving it in png format
linearFloatImg.ToPixImage<byte>().Save(Path.Combine(dir, "v-linear-color.png"));
// loading a byte image
var bImg = new PixImage<byte>(Path.Combine(dir, "v-color-image.png"));
byte threshold = 2;
var isSame = byteImg.Volume.InnerProduct(
bImg.Volume, (b1, b2) => Fun.Abs(b2-b1) < threshold,
true, (equal, pixEqual) => equal && pixEqual, equal => !equal);
// replacing a border of 50 pixels by replicating the 1-pixel frame inside
// the border outwards
bImg.Volume.ReplicateBorder(new Border2l(50));
// acessing pixels of a byte image as C3b's
var c3bmatrix = bImg.GetMatrix<C3b>();
// var copiedMatrix = c3bmatrix.Copy();
var newC3fImage = c3bmatrix.ToPixImage<float>();
// setting a region in the matrix
c3bmatrix.SetRectangleFilled(48, 48, 52, 52, C3b.Black); // min x, min y, max x, max y
if (alternative)
{
// this is equivalent to:
c3bmatrix.SubMatrix(48, 48, 5, 5).Set(C3b.Black); // start x, start y, size x, size y
}
// accessing a single pixel of the matrix
c3bmatrix[50, 50] = C3b.VRVisGreen;
var size = c3bmatrix.Size;
// draw a bresenham line
c3bmatrix.SetLine(size.X - 50, 50, 50, size.Y - 50, C3b.Blue);
// draw a bresenham circle
c3bmatrix.SetCircle(size.X / 2, size.Y / 2, 50, C3b.Yellow);
c3bmatrix.SetCircleFilled((size.X * 3) / 4, (size.Y * 3) / 4, 50, C3b.Yellow);
c3bmatrix.SetCircleFilled(25, 25, 75, C3b.Yellow);
var cx = size.X / 2; var cy = size.Y / 2;
for (int i = 0; i < 36; i++)
{
var alpha = i * 2 * Constant.Pi / 36;
var dx = Fun.Cos(alpha);
var dy = Fun.Sin(alpha);
c3bmatrix.SetLineAllTouchedRaw(cx + 64 * dx, cy + 64 * dy, cx + 128 * dx, cy + 128 * dy,
C3b.Yellow);
}
// writing the image with the replicated border as a png
bImg.Save(Path.Combine(dir, "v-border-drawing.png"));
Report.End();
}
public static void Difference(string dir)
{
var idir = Path.Combine(dir, "in");
var odir = Path.Combine(dir, "out");
var hiliteImg = new PixImage<float>(Path.Combine(idir, "ref_hilite.png"));
var luxImg = new PixImage<float>(Path.Combine(idir, "ref_lux.png"));
var diffImg = new PixImage<float>(Col.Format.RGB, hiliteImg.Size);
diffImg.Volume.SetMap2(hiliteImg.Volume, luxImg.Volume, (a, b) => Fun.Abs(b - a));
var outImg = diffImg.ToPixImage<ushort>();
outImg.Save(Path.Combine(odir, "difference.tiff"));
}
public static void CopyTest(string dir)
{
var idir = Path.Combine(dir, "in");
var odir = Path.Combine(dir, "out");
var src = new PixImage<byte>(Path.Combine(idir, "rgb8.jpg")); //.ToGrayscalePixImage();
var image = new PixImage<byte>(src.Format, src.Size);
var srcvolume = src.Volume;
// var copyvol = srcvolume.Copy(); // does not work, creates default volume layout!
var copyvol = srcvolume.CopyToImage(); // works since it creates default image layout!
image.Volume = copyvol;
image.Save(Path.Combine(idir, "rgb8-copied.jpg"));
}
public static void LinearRampDemo(string dir)
{
Report.BeginTimed("linear ramp demo");
var width = 1920;
var height = 1080;
var barHeight = height/4;
var line = new byte[width].SetByIndex(
i => Col.DoubleToByte((double)i / (double)(width - 1)));
// write an image with linear red, green, blue, and gray ramps
var linearImage = new PixImage<byte>(Col.Format.RGB, new V2i(width, height));
var linVol = linearImage.Volume;
linVol.SubVolume(0, 0, 0, width, barHeight, 1).AsMatrixWindow().SetByCoord((x, y) => line[x]);
linVol.SubVolume(0, barHeight, 1, width, barHeight, 1).AsMatrixWindow().SetByCoord((x, y) => line[x]);
linVol.SubVolume(0, 2 * barHeight, 2, width, barHeight, 1).AsMatrixWindow().SetByCoord((x, y) => line[x]);
linVol.SubVolume(0, 3 * barHeight, 0, width, barHeight, 3).SetByCoord((x, y, c) => line[x]);
linearImage.Save(Path.Combine(dir, "linear-ramp.tiff"));
Report.End();
}
}
}