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 @@ ...@@ -46,6 +46,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Filter.cs" />
<Compile Include="MultiThreadedTask.cs" /> <Compile Include="MultiThreadedTask.cs" />
<Compile Include="MyImage.cs" /> <Compile Include="MyImage.cs" />
<Compile Include="Display.cs" /> <Compile Include="Display.cs" />
......
...@@ -12,131 +12,71 @@ namespace S04_Projet ...@@ -12,131 +12,71 @@ namespace S04_Projet
class Program class Program
{ {
public static bool MULTITHREADING_LOAD = false; public static bool MULTITHREADING_LOAD = false;
public static bool MULTITHREADING = true; public static bool MULTITHREADING = false;
static void Main(string[] args) public static bool DEBUG = false;
{ public static MyImage img;
#region Filters Matrix public static Stopwatch sw = new Stopwatch();
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[,] static void Main(string[] args)
{
{ 1, 0, -1 },
{ 0, 0, 0 },
{ -1, 0, 1 }
};
short[,] edgeDetect2Filter = new short[,]
{
{ 0, 1, 0 },
{ 1, -4, 1 },
{ 0, 1, 0 }
};
short[,] edgeDetect3Filter = new short[,]
{ {
{ -1, -1, -1 }, Arguments(args, 0);
{ -1, 8, -1 }, }
{ -1, -1, -1 }
};
short[,] sharpenFilter = new short[,] private static void Arguments(string[] args, int i)
{ {
{ 0, -1, 0 }, int increment = 1;
{ -1, 5, -1 }, if (DEBUG) sw.Restart();
{ 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();
/* if (args[i] == "--input" || args[i] == "-i")
#region Arguments
if (args.Length > 0)
{ {
MULTITHREADING = false; img = new MyImage(args[i + 1]);
bool filter = false; increment = 2;
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 != "") else if (args[i] == "--output" || args[i] == "-o")
{ {
MyImage img = new MyImage(inputPath); if (img != null) img.Save(args[i + 1]);
if (filter) img = img.ApplyConvFilter(edgeDetect1Filter, 1); increment = 2;
if (outputPath != "")
{
img.Save(outputPath);
} else
{
Console.WriteLine("No output specified, program will only load image in memory and stop");
} }
else if (args[i] == "--debug" || args[i] == "-d")
DEBUG = true;
} else else if (args[i] == "--multithreading" || args[i] == "-MT")
{ MULTITHREADING = true;
Console.WriteLine("--input argument required"); else if (args[i] == "--filter" || args[i] == "-f")
{
increment = 2;
int choix = 0;
switch (args[i + 1].ToLower())
{
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]);
#endregion };
#region Display
else
{
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) if (DEBUG)
{ {
ToDo = Display.AskForOperation(); sw.Stop();
newImg = Display.PerformOperation(ToDo, newImg); File.AppendAllText("debug.csv", args[i].Replace("-", "") + ";" + sw.ElapsedMilliseconds + ";\n");
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Image sauvegardée en {0}ms!", Display.elapsedTime);
Console.Read();
} }
#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