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;
public static bool DEBUG = false;
public static MyImage img;
public static Stopwatch sw = new Stopwatch();
static void Main(string[] args) static void Main(string[] args)
{ {
#region Filters Matrix Arguments(args, 0);
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 }
};
short[,] edgeDetect3Filter = new short[,] private static void Arguments(string[] args, int i)
{ {
{ -1, -1, -1 }, int increment = 1;
{ -1, 8, -1 }, if (DEBUG) sw.Restart();
{ -1, -1, -1 }
};
short[,] sharpenFilter = new short[,] if (args[i] == "--input" || args[i] == "-i")
{ {
{ 0, -1, 0 }, img = new MyImage(args[i + 1]);
{ -1, 5, -1 }, increment = 2;
{ 0, -1, 0 } }
}; else if (args[i] == "--output" || args[i] == "-o")
#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)
{ {
MULTITHREADING = false; if (img != null) img.Save(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 != "")
{
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");
}
} }
#endregion else if (args[i] == "--debug" || args[i] == "-d")
DEBUG = true;
#region Display else if (args[i] == "--multithreading" || args[i] == "-MT")
else MULTITHREADING = true;
else if (args[i] == "--filter" || args[i] == "-f")
{ {
Console.ForegroundColor = ConsoleColor.White; increment = 2;
Console.WriteLine("#############################################################"); int choix = 0;
Console.WriteLine("### Bienvenue ###"); switch (args[i + 1].ToLower())
Console.WriteLine("#############################################################");
Console.WriteLine();
MyImage img = Display.LoadImage();
Display.Operation ToDo = Display.AskForOperation();
MyImage newImg = Display.PerformOperation(ToDo, img);
while (newImg != null)
{ {
ToDo = Display.AskForOperation(); case "flou":
newImg = Display.PerformOperation(ToDo, newImg); 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; if (DEBUG)
Console.WriteLine("Image sauvegardée en {0}ms!", Display.elapsedTime); {
sw.Stop();
Console.Read(); 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