Commit bef5662b authored by BORNON Théophile's avatar BORNON Théophile

Begining of enlarge gradient. Enlarge done

parent 7531c00a
......@@ -27,22 +27,14 @@ namespace S04_Projet
private short[,] filter;
private double factor;
private int size;
//private double stepSize;
private Operation ToDo;
#endregion
public void SetNbPixel(int nbPixel) => this.nbPixel = nbPixel;
public void SetFile(byte[] file) => this.file = file;
private Operation ToDo;
public MultiThreadedTask(Operation ToDo, byte[] file, Options opt)
{
this.ToDo = ToDo;
this.opt = opt;
this.file = file;
nbPixel = opt.width * opt.height;
nbProcessors = Environment.ProcessorCount;
}
public unsafe MultiThreadedTask(Operation ToDo, byte* rPixelPtr, byte* gPixelPtr, byte* bPixelPtr, Options opt, short[,] filter, double factor)
{
......@@ -58,21 +50,33 @@ namespace S04_Projet
nbProcessors = 4;
}
public unsafe MultiThreadedTask(Operation ToDo, Options opt, byte* rPixelPtr, byte* gPixelPtr, byte* bPixelPtr)
{
this.ToDo = ToDo;
this.rPixelPtr = rPixelPtr;
this.gPixelPtr = gPixelPtr;
this.bPixelPtr = bPixelPtr;
nbPixel = opt.width * opt.height;
}
#region Filter
public MyImage ApplyFilter()
{
int nbPixel = opt.width * opt.height;
int pixelPerThread = nbPixel / nbProcessors;
NewRMatrix = new byte[nbPixel];
NewGMatrix = new byte[nbPixel];
NewBMatrix = new byte[nbPixel];
//stepSize = (Math.E - 1) / nbProcessors;
Thread[] threads = new Thread[nbProcessors];
Console.WriteLine("Creating {0} thread(s)", nbProcessors);
for (int i = 0; i < nbProcessors; i++)
{
threads[i] = new Thread(new ParameterizedThreadStart(ApplyFilterTask));
//double param = 1 + i * stepSize;
threads[i].Start(i);
}
......@@ -87,8 +91,19 @@ namespace S04_Projet
private unsafe void ApplyFilterTask(object i)
{
int x, y;
int start = opt.width * opt.height / nbProcessors * (int)i;
int end = opt.width * opt.height / nbProcessors * ((int)i + 1);
int nbPixel = opt.width * opt.height;
int start = nbPixel / nbProcessors * (int)i;
int end = nbPixel / nbProcessors * ((int)i + 1);
/*double param = (double)i;
int start = (int)(Math.Log(param) * nbPixel);
int end;
if (param + stepSize < Math.E) end = (int)(Math.Log(param + stepSize) * nbPixel);
else end = nbPixel;
Console.WriteLine((double)i + "Start : " + start);
Console.WriteLine((double)i + "End : " + end);*/
byte[,] rMatrix = new byte[size, size];
byte[,] gMatrix = new byte[size, size];
byte[,] bMatrix = new byte[size, size];
......
This diff is collapsed.
......@@ -24,7 +24,7 @@ namespace S04_Projet
public int fileSize;
public int offset;
public Options() { }
public Options() {}
/// <summary>
/// Return a new instance of Options with the same parameters
......@@ -32,22 +32,24 @@ namespace S04_Projet
/// <returns>New option instance</returns>
public Options Copy()
{
Options options = new Options();
options.fileInfoHeaderSize = fileInfoHeaderSize;
options.width = width;
options.height = height;
options.padding = padding;
options.colorPlanesNb = colorPlanesNb;
options.bitsPerPixel = bitsPerPixel;
options.compressionMethod = compressionMethod;
options.imgSize = imgSize;
options.horizontalRes = horizontalRes;
options.VerticalRes = VerticalRes;
options.nbColor = nbColor;
options.nbImportantColor = nbImportantColor;
options.format = format;
options.fileSize = fileSize;
options.offset = offset;
Options options = new Options
{
fileInfoHeaderSize = fileInfoHeaderSize,
width = width,
height = height,
padding = padding,
colorPlanesNb = colorPlanesNb,
bitsPerPixel = bitsPerPixel,
compressionMethod = compressionMethod,
imgSize = imgSize,
horizontalRes = horizontalRes,
VerticalRes = VerticalRes,
nbColor = nbColor,
nbImportantColor = nbImportantColor,
format = format,
fileSize = fileSize,
offset = offset
};
return options;
}
......
......@@ -60,12 +60,12 @@ namespace S04_Projet
Stopwatch sw = new Stopwatch();
MyImage imgg = new MyImage("img/flocon.bmp");
MyImage imgg = new MyImage("img/image.bmp");
Console.WriteLine("Loading done");
sw.Start();
MyImage newImg = imgg.Filter(sharpenFilter, 1);
MyImage filter = imgg.Filter(edgeDetect3Filter, 1);
sw.Stop();
newImg.Save("filter.bmp");
filter.Save("filter.bmp");
Console.WriteLine(sw.ElapsedMilliseconds);
Console.Read();
......
This diff is collapsed.
This image diff could not be displayed because it is too large. You can view the blob instead.
S04_Projet/bin/Debug/img/coco.bmp

188 KB | W: | H:

S04_Projet/bin/Debug/img/coco.bmp

188 KB | W: | H:

S04_Projet/bin/Debug/img/coco.bmp
S04_Projet/bin/Debug/img/coco.bmp
S04_Projet/bin/Debug/img/coco.bmp
S04_Projet/bin/Debug/img/coco.bmp
  • 2-up
  • Swipe
  • Onion skin
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