Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Rotate270.cs
1using System;
2
4{
8 public static partial class LinearTransformationOperations
9 {
15 public static Matrix<T> Rotate270<T>(this Matrix<T> M)
16 where T : struct
17 {
18 int w = M.Width;
19 int h = M.Height;
20 Matrix<T> Result = new(h, w);
21 T[] Src = M.Data;
22 int SrcIndex;
23 int SrcRowSize = M.RowSize;
24 T[] Dest = Result.Data;
25 int DestIndex = 0;
26 int x, y;
27
28 for (y = 0; y < w; y++)
29 {
30 SrcIndex = M.StartIndex(w - y - 1, 0);
31 for (x = 0; x < h; x++)
32 {
33 Dest[DestIndex++] = Src[SrcIndex];
34 SrcIndex += SrcRowSize;
35 }
36 }
37
38 return Result;
39 }
40
46 public static IMatrix Rotate270(this IMatrix M)
47 {
48 if (M is Matrix<float> M2)
49 return M2.Rotate270();
50 else if (M is Matrix<int> M3)
51 return M3.Rotate270();
52 else if (M is Matrix<uint> M4)
53 return M4.Rotate270();
54 else if (M is Matrix<byte> M5)
55 return M5.Rotate270();
56 else
57 throw new ArgumentException("Unsupported type: " + M.GetType().FullName, nameof(M));
58 }
59 }
60}
Implements a Matrix, basic component for computations in Image Processing and Computer Vision.
Definition: Matrix.cs:12
T[] Data
Underlying data on which the matrix is defined.
Definition: Matrix.cs:114
static Matrix< T > Rotate270< T >(this Matrix< T > M)
Rotates the image 270 degrees to the right.
Definition: Rotate270.cs:15
static IMatrix Rotate270(this IMatrix M)
Rotates the image 270 degrees to the right.
Definition: Rotate270.cs:46
Interface for matrices.
Definition: IMatrix.cs:9