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

Test

parent 45249fb9
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace S04_Projet
{
class Filter
{
public static string[] Noms = new string[] {
"Augmenter le contraste",
"Flou",
"Renforcement des bords",
"Détection des bords",
"Repoussage"
};
public static double[] Facteurs = new double[] { 1, 1 / 9.0, 1, 1, 1 };
private static short[,] contrastPlus = new short[,]
{
{ 0,-1, 0 },
{-1, 5,-1 },
{ 0,-1, 0 }
};
private static short[,] flou = new short[,]
{
{ 1, 1, 1 },
{ 1, 1, 1 },
{ 1, 1, 1 }
};
private static short[,] renforcement = new short[,]
{
{ 0, 0, 0 },
{-1, 1, 0 },
{ 0, 0, 0 }
};
private static short[,] detection = new short[,]
{
{ 0, 1, 0 },
{ 1,-4, 1 },
{ 0, 1, 0 }
};
private static short[,] repoussage = new short[,]
{
{-2,-1, 0 },
{-1, 1, 1 },
{ 0, 1, 2 }
};
public static List<short[,]> Filtres = new List<short[,]>() { contrastPlus, flou, renforcement, detection, repoussage };
}
}
......@@ -46,6 +46,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Filter.cs" />
<Compile Include="MultiThreadedTask.cs" />
<Compile Include="MyImage.cs" />
<Compile Include="Display.cs" />
......
......@@ -12,131 +12,71 @@ namespace S04_Projet
class Program
{
public static bool MULTITHREADING_LOAD = false;
public static bool MULTITHREADING = true;
public static bool MULTITHREADING = false;
public static bool DEBUG = false;
public static MyImage img;
public static Stopwatch sw = new Stopwatch();
static void Main(string[] args)
{
#region Filters Matrix
short[,] boxBlurFilter = new short[,] {
{1,1,1 },
{1,1,1 },
{1,1,1 }
};
short[,] identityFilter = new short[,]
{
{ 0, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 0 }
};
short[,] edgeDetect1Filter = new short[,]
{
{ 1, 0, -1 },
{ 0, 0, 0 },
{ -1, 0, 1 }
};
short[,] edgeDetect2Filter = new short[,]
{
{ 0, 1, 0 },
{ 1, -4, 1 },
{ 0, 1, 0 }
};
Arguments(args, 0);
}
short[,] edgeDetect3Filter = new short[,]
{
{ -1, -1, -1 },
{ -1, 8, -1 },
{ -1, -1, -1 }
};
private static void Arguments(string[] args, int i)
{
int increment = 1;
if (DEBUG) sw.Restart();
short[,] sharpenFilter = new short[,]
if (args[i] == "--input" || args[i] == "-i")
{
{ 0, -1, 0 },
{ -1, 5, -1 },
{ 0, -1, 0 }
};
#endregion
Stopwatch sw = new Stopwatch();
MyImage imgg = new MyImage("img/flocon.bmp");
Console.WriteLine("Loading done");
sw.Start();
imgg.ApplyConvFilter(edgeDetect1Filter, 1);
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
Console.Read();
/*
#region Arguments
if (args.Length > 0)
img = new MyImage(args[i + 1]);
increment = 2;
}
else if (args[i] == "--output" || args[i] == "-o")
{
MULTITHREADING = false;
bool filter = false;
string inputPath = "";
string outputPath = "";
for (int i = 0; i < args.Length; i++)
{
if (args[i].Equals("--input"))
{
inputPath = args[i + 1];
i++;
}
else if (args[i].Equals("--output"))
{
outputPath = args[i + 1];
i++;
}
else if (args[i].Equals("--multithreading")) MULTITHREADING = true;
else if (args[i].Equals("--filter")) filter = true;
}
if(inputPath != "")
{
MyImage img = new MyImage(inputPath);
if (filter) img = img.ApplyConvFilter(edgeDetect1Filter, 1);
if (outputPath != "")
{
img.Save(outputPath);
} else
{
Console.WriteLine("No output specified, program will only load image in memory and stop");
}
} else
{
Console.WriteLine("--input argument required");
}
if (img != null) img.Save(args[i + 1]);
increment = 2;
}
#endregion
#region Display
else
else if (args[i] == "--debug" || args[i] == "-d")
DEBUG = true;
else if (args[i] == "--multithreading" || args[i] == "-MT")
MULTITHREADING = true;
else if (args[i] == "--filter" || args[i] == "-f")
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("#############################################################");
Console.WriteLine("### Bienvenue ###");
Console.WriteLine("#############################################################");
Console.WriteLine();
MyImage img = Display.LoadImage();
Display.Operation ToDo = Display.AskForOperation();
MyImage newImg = Display.PerformOperation(ToDo, img);
while (newImg != null)
increment = 2;
int choix = 0;
switch (args[i + 1].ToLower())
{
ToDo = Display.AskForOperation();
newImg = Display.PerformOperation(ToDo, newImg);
case "flou":
case "blur":
choix = 1;
break;
case "edgedetection":
case "detectionbord":
choix = 3;
break;
case "renforcement":
case "reinforcement":
choix = 2;
break;
case "repoussage":
case "spinning":
choix = 4;
break;
case "constraste":
case "constrast":
choix = 0;
break;
}
img = img.ApplyConvFilter(Filter.Filtres[choix], Filter.Facteurs[choix]);
};
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Image sauvegardée en {0}ms!", Display.elapsedTime);
Console.Read();
if (DEBUG)
{
sw.Stop();
File.AppendAllText("debug.csv", args[i].Replace("-", "") + ";" + sw.ElapsedMilliseconds + ";\n");
}
#endregion
*/
if (i + increment < args.Length) Arguments(args, i + increment);
}
}
}
@echo off
FOR /L %%i IN (1,1,20) DO (
ECHO %%i
ImageProcessing.exe -d -MT -i img\flocon.bmp -f flou -o output.bmp
)
\ No newline at end of file
@echo off
FOR /L %%i IN (1,1,20) DO (
ECHO %%i
ImageProcessing.exe -d -i img\flocon.bmp -f flou -o output.bmp
)
\ No newline at end of file
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