Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
BlueChannel.cs
1using System;
2
3namespace IdApp.Cv.Channels
4{
8 public static partial class ChannelOperations
9 {
16 {
17 int y, h = M.Height;
18 int x, w = M.Width;
19 int SrcOffset = M.Start;
20 int DestOffset = 0;
21 int SrcSkip = M.Skip;
22 uint[] Src = M.Data;
23 byte[] Dest = new byte[w * h];
24
25 for (y = 0; y < h; y++, SrcOffset += SrcSkip)
26 {
27 for (x = 0; x < w; x++)
28 Dest[DestOffset++] = (byte)(Src[SrcOffset++] >> 16);
29 }
30
31 return new Matrix<byte>(w, h, Dest);
32 }
33
39 public static IMatrix BlueChannel(this IMatrix M)
40 {
41 if (M is Matrix<uint> M2)
42 return BlueChannel(M2);
43 else
44 throw new ArgumentException("Unsupported type: " + M.GetType().FullName, nameof(M));
45 }
46 }
47}
static Matrix< byte > BlueChannel(this Matrix< uint > M)
Creates a matrix of pixel blue channel values.
Definition: BlueChannel.cs:15
static IMatrix BlueChannel(this IMatrix M)
Creates a matrix of pixel blue channel values.
Definition: BlueChannel.cs:39
Implements a Matrix, basic component for computations in Image Processing and Computer Vision.
Definition: Matrix.cs:12
int Height
Height of matrix (number of rows)
Definition: Matrix.cs:136
T[] Data
Underlying data on which the matrix is defined.
Definition: Matrix.cs:114
int Width
Width of matrix (number of columns)
Definition: Matrix.cs:120
int Skip
Number of elements to skip from the right edge in the underlying data to the left edge of the new row...
Definition: Matrix.cs:233
int Start
Start offset of matrix in underlying data.
Definition: Matrix.cs:228
Interface for matrices.
Definition: IMatrix.cs:9