-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathImageManager.cs
More file actions
59 lines (50 loc) · 1.61 KB
/
ImageManager.cs
File metadata and controls
59 lines (50 loc) · 1.61 KB
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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ACVI_Eigenfaces.Logic
{
public static class ImageManager
{
private static int width;
private static int height;
public static byte[] ConvertImageToVector(Bitmap Image)
{
byte[] vector = new byte[Image.Width*Image.Height];
height = Image.Height;
width = Image.Width;
int positionCounter = 0;
for(int i = 0; i<Image.Width;i++)
{
for(int j = 0; j<Image.Height;j++)
{
vector[positionCounter] = Image.GetPixel(i, j).R;
Color color = Image.GetPixel(i, j);
positionCounter++;
}
}
return vector;
}
public static Bitmap ConvertVectorToImage(byte[] pixels)
{
Bitmap image = new Bitmap(width, height);
int positionCounter = 0;
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
Color color = Color.FromArgb(255, pixels[positionCounter], pixels[positionCounter],
pixels[positionCounter]);
positionCounter++;
image.SetPixel(i,j,color);
}
}
return image;
}
//public BufferedImage ConvertVectorToImage(int[] ImageVector)
//{
//}
}
}