Commit 6c0d4b85 authored by BORNON Théophile's avatar BORNON Théophile

Superposition

parent bef5662b
......@@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessing", "S04_Proj
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
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -23,10 +21,6 @@ Global
{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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -393,7 +393,7 @@ namespace S04_Projet
return new MyImage(options, newPixelR, newPixelG, newPixelB);
}
private unsafe byte[] GenerateGradient(int x, int y, int coeff, RGB rgb, byte* rPtr, byte* gPtr, byte* bPtr)
/*private unsafe byte[] GenerateGradient(int x, int y, int coeff, RGB rgb, byte* rPtr, byte* gPtr, byte* bPtr)
{
// cf https://stackoverflow.com/a/1106986
......@@ -438,7 +438,7 @@ namespace S04_Projet
x0 = i % coeff;
y0 = i / coeff;
}
}
}*/
/// <summary>
/// Rétrécit l'image par rapport au coefficient passé en paramètres
......@@ -652,6 +652,33 @@ namespace S04_Projet
Images[2] = new MyImage(options, new byte[options.width * options.height], new byte[options.width * options.height], newBPixel);
return Images;
}
public unsafe MyImage Superposition(MyImage img, int x, int y)
{
byte[] newRPixel = rPixels;
byte[] newGPixel = gPixels;
byte[] newBPixel = bPixels;
fixed (byte* rPixelPtr = img.rPixels, gPixelPtr = img.gPixels, bPixelPtr = img.bPixels)
{
fixed (byte* newRPtr = newRPixel, newGPtr = newGPixel, newBPtr = newBPixel)
{
for (int i = 0; i < img.opt.height; i++)
{
if (y + i >= opt.height) break;
for (int j = 0; j < img.opt.width; j++)
{
if (x + j >= opt.width) break;
*(newRPtr + x + j + (y + i) * opt.width) = *(rPixelPtr + i * img.opt.width + j);
*(newGPtr + x + j + (y + i) * opt.width) = *(gPixelPtr + i * img.opt.width + j);
*(newBPtr + x + j + (y + i) * opt.width) = *(bPixelPtr + i * img.opt.width + j);
}
}
}
}
return new MyImage(opt, newRPixel, newGPixel, newBPixel);
}
#region Helpers
/// <summary>
......
......@@ -60,12 +60,13 @@ namespace S04_Projet
Stopwatch sw = new Stopwatch();
MyImage imgg = new MyImage("img/image.bmp");
MyImage img = new MyImage("img/image.bmp");
MyImage imgg = new MyImage("img/flocon.bmp");
Console.WriteLine("Loading done");
sw.Start();
MyImage filter = imgg.Filter(edgeDetect3Filter, 1);
MyImage supperposition = img.Superposition(imgg, 4000, 0);
sw.Stop();
filter.Save("filter.bmp");
supperposition.Save("sup.bmp");
Console.WriteLine(sw.ElapsedMilliseconds);
Console.Read();
......
This image diff could not be displayed because it is too large. You can view the blob instead.
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