Commit 24ab992d authored by BORNON Théophile's avatar BORNON Théophile

merge

parents c6ed9768 c43bd2bc
...@@ -5,10 +5,6 @@ VisualStudioVersion = 15.0.27004.2010 ...@@ -5,10 +5,6 @@ VisualStudioVersion = 15.0.27004.2010
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessing", "S04_Projet\ImageProcessing.csproj", "{229D3602-654B-498B-9478-5CC3982C358C}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessing", "S04_Projet\ImageProcessing.csproj", "{229D3602-654B-498B-9478-5CC3982C358C}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessing_Benchmark", "ImageProcessing_Benchmark\ImageProcessing_Benchmark.csproj", "{54D04E0E-009D-4928-BEF8-B2FF464536CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessing_Test", "ImageProcessing_Test\ImageProcessing_Test.csproj", "{F0906169-0946-4552-A06C-1D57C52B1C10}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -19,14 +15,6 @@ Global ...@@ -19,14 +15,6 @@ Global
{229D3602-654B-498B-9478-5CC3982C358C}.Debug|Any CPU.Build.0 = Debug|Any CPU {229D3602-654B-498B-9478-5CC3982C358C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{229D3602-654B-498B-9478-5CC3982C358C}.Release|Any CPU.ActiveCfg = Release|Any CPU {229D3602-654B-498B-9478-5CC3982C358C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{229D3602-654B-498B-9478-5CC3982C358C}.Release|Any CPU.Build.0 = Release|Any CPU {229D3602-654B-498B-9478-5CC3982C358C}.Release|Any CPU.Build.0 = Release|Any CPU
{54D04E0E-009D-4928-BEF8-B2FF464536CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{54D04E0E-009D-4928-BEF8-B2FF464536CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54D04E0E-009D-4928-BEF8-B2FF464536CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54D04E0E-009D-4928-BEF8-B2FF464536CC}.Release|Any CPU.Build.0 = Release|Any CPU
{F0906169-0946-4552-A06C-1D57C52B1C10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0906169-0946-4552-A06C-1D57C52B1C10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0906169-0946-4552-A06C-1D57C52B1C10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0906169-0946-4552-A06C-1D57C52B1C10}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
This diff is collapsed.
...@@ -6,7 +6,7 @@ using System.Threading.Tasks; ...@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace S04_Projet namespace S04_Projet
{ {
class Filter public class Filter
{ {
public static string[] Noms = new string[] { public static string[] Noms = new string[] {
"Augmenter le contraste", "Augmenter le contraste",
......
...@@ -47,11 +47,11 @@ ...@@ -47,11 +47,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Filter.cs" /> <Compile Include="Filter.cs" />
<Compile Include="Menu.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" />
<Compile Include="Options.cs" /> <Compile Include="Options.cs" />
<Compile Include="Pixel.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace S04_Projet
{
class Menu
{
private string[] menuItems;
public Menu(string[] menuItems)
{
this.menuItems = menuItems;
}
public int ShowMenu(int xOffset, int yOffset)
{
int choosenItem = 0;
Console.SetCursorPosition(xOffset, yOffset);
for (int i = 0; i < menuItems.Length; i++)
{
Console.WriteLine(((choosenItem == i) ? ">> " : " ") + menuItems[i]);
}
ConsoleKeyInfo key;
do
{
key = Console.ReadKey();
Console.SetCursorPosition(xOffset, yOffset + choosenItem);
Console.Write(" ");
if (key.Key == ConsoleKey.DownArrow)
{
choosenItem++;
if (choosenItem == menuItems.Length) choosenItem = 0;
}
else if (key.Key == ConsoleKey.UpArrow)
{
choosenItem--;
if (choosenItem == -1) choosenItem = menuItems.Length - 1;
}
Console.SetCursorPosition(xOffset, yOffset + choosenItem);
Console.Write(">>");
} while (key.Key != ConsoleKey.Escape && key.Key != ConsoleKey.Enter);
if (key.Key == ConsoleKey.Escape) Environment.Exit(0);
return choosenItem;
}
}
}
This diff is collapsed.
This diff is collapsed.
...@@ -24,7 +24,7 @@ namespace S04_Projet ...@@ -24,7 +24,7 @@ namespace S04_Projet
public int fileSize; public int fileSize;
public int offset; public int offset;
public Options() { } public Options() {}
/// <summary> /// <summary>
/// Return a new instance of Options with the same parameters /// Return a new instance of Options with the same parameters
...@@ -32,22 +32,24 @@ namespace S04_Projet ...@@ -32,22 +32,24 @@ namespace S04_Projet
/// <returns>New option instance</returns> /// <returns>New option instance</returns>
public Options Copy() public Options Copy()
{ {
Options options = new Options(); Options options = new Options
options.fileInfoHeaderSize = fileInfoHeaderSize; {
options.width = width; fileInfoHeaderSize = fileInfoHeaderSize,
options.height = height; width = width,
options.padding = padding; height = height,
options.colorPlanesNb = colorPlanesNb; padding = padding,
options.bitsPerPixel = bitsPerPixel; colorPlanesNb = colorPlanesNb,
options.compressionMethod = compressionMethod; bitsPerPixel = bitsPerPixel,
options.imgSize = imgSize; compressionMethod = compressionMethod,
options.horizontalRes = horizontalRes; imgSize = imgSize,
options.VerticalRes = VerticalRes; horizontalRes = horizontalRes,
options.nbColor = nbColor; VerticalRes = VerticalRes,
options.nbImportantColor = nbImportantColor; nbColor = nbColor,
options.format = format; nbImportantColor = nbImportantColor,
options.fileSize = fileSize; format = format,
options.offset = offset; fileSize = fileSize,
offset = offset
};
return options; return options;
} }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace S04_Projet
{
public class Pixel
{
public byte r { get; private set; }
public byte g { get; private set; }
public byte b { get; private set; }
public double H { get; private set; }
public double S { get; private set; }
public double L { get; private set; }
public void SetR(byte r) => this.r = r;
public void SetG(byte g) => this.g = g;
public void SetB(byte b) => this.b = b;
/// <summary>
/// Prend les trois couleurs en paramètres
/// </summary>
/// <param name="r">Rouge</param>
/// <param name="g">Vert</param>
/// <param name="b">Bleu</param>
public Pixel(byte r, byte g, byte b)
{
this.r = r;
this.g = g;
this.b = b;
}
public unsafe Pixel(byte* r, byte* g, byte* b)
{
this.r = *r;
this.g = *g;
this.b = *b;
}
/// <summary>
/// Assigne une même valeur à toutes les couleurs
/// </summary>
/// <param name="unifiedColors">Valeur souhaitée pour toutes les couleurs</param>
public Pixel(byte unifiedColors)
{
r = unifiedColors;
g = unifiedColors;
b = unifiedColors;
}
/// <summary>
/// Créer un pixel à partir d'un tableau contenant les couleurs rouge, vert, bleu (respectivement)
/// </summary>
/// <param name="rgb">Tableau composé dans cet ordre des couleurs rouge, vert, bleu</param>
public Pixel(byte[] rgb)
{
r = rgb[0];
g = rgb[1];
b = rgb[2];
}
/// <summary>
/// Créer un pixel à partir d'un tableau contenant les couleurs rouge, vert, bleu (respectivement)
/// </summary>
/// <param name="rgb">Tableau composé dans cet ordre des couleurs rouge, vert, bleu</param>
public Pixel(int[] rgb)
{
r = (byte)rgb[0];
g = (byte)rgb[1];
b = (byte)rgb[2];
}
/// <summary>
/// Retourne un tableau contenant les valeurs RGB du pixel
/// </summary>
/// <returns>Composantes rouge, verte et bleue du pixel</returns>
public byte[] getRGB()
{
return new byte[] { r, g, b };
}
public unsafe byte* getRGBPtr()
{
unsafe
{
fixed (byte* ptr = new byte[] { r, g, b })
return ptr;
}
}
public byte[] getBGR()
{
return new byte[] { b, g, r };
}
/// <summary>
/// Retourne l'équavalent gris d'un pixel
/// </summary>
/// <param name="scale">Nombre de nuances de gris</param>
/// <returns>Pixel en échelle de gris</returns>
public Pixel getGrayScale(byte scale)
{
byte total = (byte)((r + g + b) / 3);
total = (byte)(Math.Round((double)total / (255 / (scale - 1))) * (255 / (scale - 1)));
return new Pixel(total);
}
/// <summary>
/// Retourne l'équivalent gris d'un pixel en prenant en compte les coefficients de luminosité
/// des couleurs RGB
/// </summary>
/// <param name="scale"></param>
/// <returns></returns>
public Pixel getGrayScaleLuminosity(byte scale)
{
byte total = (byte)(0.21 * r + 0.72 * g + 0.07 * b);
total = (byte)(Math.Round((double)total / (255 / (scale - 1))) * (255 / (scale - 1)));
return new Pixel(total);
}
/// <summary>
/// Calcul les valeurs de variables HSL (Hue, Saturation, Lightness)
/// </summary>
private void computeHSL()
{
double rH = r / 255.0;
double gH = g / 255.0;
double bH = b / 255.0;
double Cmax = Math.Max(Math.Max(rH, gH), bH);
double Cmin = Math.Min(Math.Min(rH, gH), bH);
double delta = Cmax - Cmin;
L = (Cmin + Cmax) / 2.0;
if (delta == 0) S = 0;
else S = delta / (1.0 - Math.Abs(2.0 * L - 1));
if (delta == 0) H = 0;
else if (Cmax == rH) H = 60 * (((gH - bH) / delta) % 6);
else if (Cmax == gH) H = 60 * (((bH - rH) / delta) + 2);
else H = 60 * (((rH - gH) / delta) + 4);
}
}
}
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Drawing;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
...@@ -11,15 +6,63 @@ namespace S04_Projet ...@@ -11,15 +6,63 @@ namespace S04_Projet
{ {
class Program class Program
{ {
public static bool MULTITHREADING_LOAD = false; //public static bool MULTITHREADING_LOAD = false;
public static bool MULTITHREADING = false; public static bool MULTITHREADING = false;
public static int MAX_THREADS = Environment.ProcessorCount;
public static bool DEBUG = false; public static bool DEBUG = false;
public static MyImage img;
public static Stopwatch sw = new Stopwatch(); private static string[] menuItems = new string[] { "Charger une image", "Créer une image" };
private static Menu welcomeMenu = new Menu(menuItems);
private static MyImage img;
private static Stopwatch sw = new Stopwatch();
static void Main(string[] args) static void Main(string[] args)
{ {
Arguments(args, 0); #region Arguments
if (args.Length > 0)
{
Arguments(args, 0);
}
#endregion
#region Display
else
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("#############################################################");
Console.WriteLine("### Bienvenue ###");
Console.WriteLine("#############################################################");
Console.WriteLine();
int choice = welcomeMenu.ShowMenu(0, 5); // 0 pour charger une image, 1 pour la créer
if (choice == 0)
{
Console.Clear();
img = Display.LoadImage();
}
else
{
Console.Clear();
img = Display.CreateImageOperation();
Display.fileInfos = img.ToString();
}
Display.Operation ToDo = Display.AskForOperation();
MyImage newImg = Display.PerformOperation(ToDo, img);
while (newImg != null)
{
ToDo = Display.AskForOperation();
newImg = Display.PerformOperation(ToDo, newImg);
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Image sauvegardée en {0}ms!", Display.elapsedTime);
Console.Read();
}
#endregion
} }
private static void Arguments(string[] args, int i) private static void Arguments(string[] args, int i)
...@@ -45,7 +88,7 @@ namespace S04_Projet ...@@ -45,7 +88,7 @@ namespace S04_Projet
{ {
increment = 2; increment = 2;
int choix = 0; int choix = 0;
switch (args[i + 1].ToLower()) switch(args[i+1].ToLower())
{ {
case "flou": case "flou":
case "blur": case "blur":
...@@ -68,13 +111,18 @@ namespace S04_Projet ...@@ -68,13 +111,18 @@ namespace S04_Projet
choix = 0; choix = 0;
break; break;
} }
img = img.ApplyConvFilter(Filter.Filtres[choix], Filter.Facteurs[choix]); img = img.Filter(Filter.Filtres[choix], Filter.Facteurs[choix]);
}; }
else if (args[i] == "--threads" || args[i] == "-t")
{
MAX_THREADS = int.Parse(args[i + 1]);
increment = 2;
}
if (DEBUG) if (DEBUG)
{ {
sw.Stop(); sw.Stop();
File.AppendAllText("debug.csv", args[i].Replace("-", "") + ";" + sw.ElapsedMilliseconds + ";\n"); File.AppendAllText("debug.csv", args[i].Replace("-","") + ";" + sw.ElapsedMilliseconds + ";\n");
} }
if (i + increment < args.Length) Arguments(args, i + increment); if (i + increment < args.Length) Arguments(args, i + increment);
} }
......
@echo off
FOR /L %%i IN (1,1,100) DO (
ECHO %%i
ImageProcessing.exe -d -i img\flocon.bmp -f flou
)
\ No newline at end of file
@echo off
FOR /L %%i IN (1,1,100) DO (
ECHO %%i
ImageProcessing.exe -d -MT -i img\flocon.bmp -f flou
)
\ No newline at end of file
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
This image diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
@echo off
FOR /L %%i IN (1,1,100) DO (
ECHO %%i
ImageProcessing.exe -d -i img\flocon.bmp
)
\ No newline at end of file
@echo off
FOR /L %%i IN (1,1,100) DO (
ECHO %%i
ImageProcessing.exe -d -MT -i img\flocon.bmp
)
\ No newline at end of file
@echo off
FOR /L %%i IN (1,1,100) DO (
ECHO %%i
ImageProcessing.exe -d -i img\flocon.bmp -o output.bmp
)
\ No newline at end of file
@echo off
FOR /L %%i IN (1,1,100) DO (
ECHO %%i
ImageProcessing.exe -d -MT -i img\flocon.bmp -o output.bmp
)
\ No newline at end of file
@echo off
FOR /L %%i IN (1,1,30) DO (
ECHO i : %%i
FOR /L %%j IN (1,1,20) DO (
ECHO j : %%j
ImageProcessing.exe -d -MT -t %%i -i img\flocon.bmp -f flou
)
)
\ 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