Commit 7531c00a authored by BORNON Théophile's avatar BORNON Théophile

Small corrections, ML loading removed

parent 7e7e39a8
......@@ -8,7 +8,6 @@ namespace S04_Projet
#region Attributs
public enum Operation
{
Load,
Filter
}
......@@ -30,9 +29,9 @@ namespace S04_Projet
private int size;
#endregion
public void setNbPixel(int nbPixel) => this.nbPixel = nbPixel;
public void SetNbPixel(int nbPixel) => this.nbPixel = nbPixel;
public void setFile(byte[] file) => this.file = file;
public void SetFile(byte[] file) => this.file = file;
private Operation ToDo;
......@@ -54,60 +53,18 @@ namespace S04_Projet
this.rPixelPtr = rPixelPtr;
this.gPixelPtr = gPixelPtr;
this.bPixelPtr = bPixelPtr;
nbPixel = opt.width * opt.height;
size = filter.GetLength(0);
nbProcessors = 4;
}
public void Start()
{
if (ToDo == Operation.Load) LoadImage();
else if (ToDo == Operation.Filter) ApplyFilter();
}
#region LoadImage
public void LoadImage()
{
Thread[] threads = new Thread[nbProcessors];
for (int i = 0; i < nbProcessors; i++)
{
threads[i] = new Thread(new ParameterizedThreadStart(LoadImageTask));
threads[i].Start(i);
}
for (int i = 0; i < nbProcessors; i++)
threads[i].Join();
}
public void LoadImageTask(object i)
{
if (file != null)
{
int start = nbPixel / nbProcessors * (int)i;
int end = nbPixel / nbProcessors * ((int)i + 1);
int x, y;
byte r, g, b;
for (int j = start; j < end; j++)
{
x = j % opt.width;
y = j / opt.width;
b = file[j * 3 + opt.padding * y + opt.offset];
g = file[j * 3 + opt.padding * y + opt.offset + 1];
r = file[j * 3 + opt.padding * y + opt.offset + 2];
}
}
}
#endregion
#region Filter
public MyImage ApplyFilter()
{
int pixelNumber = opt.width * opt.height;
int pixelPerThread = pixelNumber / nbProcessors;
NewRMatrix = new byte[pixelNumber];
NewGMatrix = new byte[pixelNumber];
NewBMatrix = new byte[pixelNumber];
int pixelPerThread = nbPixel / nbProcessors;
NewRMatrix = new byte[nbPixel];
NewGMatrix = new byte[nbPixel];
NewBMatrix = new byte[nbPixel];
Thread[] threads = new Thread[nbProcessors];
......
......@@ -24,7 +24,7 @@ namespace S04_Projet
B
}
public Options getOptions()
public Options GetOptions()
{
return opt;
}
......@@ -365,7 +365,8 @@ namespace S04_Projet
return new MyImage(options, PixelArr);
}*/
public unsafe MyImage Filter(short[,] filter, double factor)
public unsafe MyImage
Filter(short[,] filter, double factor)
{
fixed (byte* rPixelPtr = rPixels, gPixelPtr = gPixels, bPixelPtr = bPixels)
{
......
......@@ -60,7 +60,7 @@ namespace S04_Projet
Stopwatch sw = new Stopwatch();
MyImage imgg = new MyImage("img/image.bmp");
MyImage imgg = new MyImage("img/flocon.bmp");
Console.WriteLine("Loading done");
sw.Start();
MyImage newImg = imgg.Filter(sharpenFilter, 1);
......
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment