Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imageProcessing
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ecole
imageProcessing
Commits
fb9a6f07
Commit
fb9a6f07
authored
Mar 26, 2018
by
BORNON Théophile
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bench scripts and minor changes
parent
a79faff5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
34 deletions
+81
-34
MultiThreadedTask.cs
S04_Projet/MultiThreadedTask.cs
+50
-20
MyImage.cs
S04_Projet/MyImage.cs
+22
-10
Program.cs
S04_Projet/Program.cs
+3
-3
ImageProcessing.exe
S04_Projet/bin/Debug/ImageProcessing.exe
+0
-0
loadMT.bat
S04_Projet/bin/Debug/loadMT.bat
+1
-1
loadSaveMT.bat
S04_Projet/bin/Debug/loadSaveMT.bat
+5
-0
No files found.
S04_Projet/MultiThreadedTask.cs
View file @
fb9a6f07
...
@@ -9,7 +9,8 @@ namespace S04_Projet
...
@@ -9,7 +9,8 @@ namespace S04_Projet
public
enum
Operation
public
enum
Operation
{
{
Load
,
Load
,
Filter
Filter
,
Save
}
}
private
enum
RGB
private
enum
RGB
...
@@ -60,7 +61,7 @@ namespace S04_Projet
...
@@ -60,7 +61,7 @@ namespace S04_Projet
this
.
bPixelPtr
=
bPixelPtr
;
this
.
bPixelPtr
=
bPixelPtr
;
nbPixel
=
opt
.
width
*
opt
.
height
;
nbPixel
=
opt
.
width
*
opt
.
height
;
size
=
filter
.
GetLength
(
0
);
size
=
filter
.
GetLength
(
0
);
nbProcessors
=
4
;
nbProcessors
=
Math
.
Min
(
Environment
.
ProcessorCount
,
8
)
;
}
}
else
throw
new
Exception
(
"Impossible d'utiliser ce constructeur pour ce type d'opération"
);
else
throw
new
Exception
(
"Impossible d'utiliser ce constructeur pour ce type d'opération"
);
}
}
...
@@ -76,7 +77,7 @@ namespace S04_Projet
...
@@ -76,7 +77,7 @@ namespace S04_Projet
/// <param name="filePtr"></param>
/// <param name="filePtr"></param>
public
unsafe
MultiThreadedTask
(
Operation
ToDo
,
Options
opt
,
byte
*
rPixelPtr
,
byte
*
gPixelPtr
,
byte
*
bPixelPtr
,
byte
*
filePtr
)
public
unsafe
MultiThreadedTask
(
Operation
ToDo
,
Options
opt
,
byte
*
rPixelPtr
,
byte
*
gPixelPtr
,
byte
*
bPixelPtr
,
byte
*
filePtr
)
{
{
if
(
ToDo
==
Operation
.
Load
)
if
(
ToDo
==
Operation
.
Load
||
ToDo
==
Operation
.
Save
)
{
{
this
.
rPixelPtr
=
rPixelPtr
;
this
.
rPixelPtr
=
rPixelPtr
;
this
.
gPixelPtr
=
gPixelPtr
;
this
.
gPixelPtr
=
gPixelPtr
;
...
@@ -85,20 +86,18 @@ namespace S04_Projet
...
@@ -85,20 +86,18 @@ namespace S04_Projet
this
.
opt
=
opt
;
this
.
opt
=
opt
;
this
.
filePtr
=
filePtr
;
this
.
filePtr
=
filePtr
;
nbPixel
=
opt
.
width
*
opt
.
height
;
nbPixel
=
opt
.
width
*
opt
.
height
;
nbProcessors
=
Environment
.
ProcessorCount
;
nbProcessors
=
Math
.
Min
(
Environment
.
ProcessorCount
,
8
)
;
}
}
else
throw
new
Exception
(
"Impossible d'utiliser ce constructeur pour ce type d'opération"
);
else
throw
new
Exception
(
"Impossible d'utiliser ce constructeur pour ce type d'opération"
);
}
}
#
region
Load
Image
#
region
Load
public
unsafe
void
LoadImage
()
public
unsafe
void
LoadImage
()
{
{
Console
.
WriteLine
(
"Load Image"
);
Thread
[]
threads
=
new
Thread
[
nbProcessors
];
Thread
[]
threads
=
new
Thread
[
nbProcessors
];
for
(
int
i
=
0
;
i
<
nbProcessors
;
i
++)
for
(
int
i
=
0
;
i
<
nbProcessors
;
i
++)
{
{
Console
.
WriteLine
(
"Creating and starting thread {0}"
,
i
);
threads
[
i
]
=
new
Thread
(
new
ParameterizedThreadStart
(
LoadImageTask
));
threads
[
i
]
=
new
Thread
(
new
ParameterizedThreadStart
(
LoadImageTask
));
threads
[
i
].
Start
(
i
);
threads
[
i
].
Start
(
i
);
}
}
...
@@ -108,8 +107,6 @@ namespace S04_Projet
...
@@ -108,8 +107,6 @@ namespace S04_Projet
}
}
private
unsafe
void
LoadImageTask
(
object
i
)
private
unsafe
void
LoadImageTask
(
object
i
)
{
if
(
filePtr
!=
null
)
{
{
int
start
=
nbPixel
/
nbProcessors
*
(
int
)
i
;
int
start
=
nbPixel
/
nbProcessors
*
(
int
)
i
;
int
end
=
nbPixel
/
nbProcessors
*
((
int
)
i
+
1
);
int
end
=
nbPixel
/
nbProcessors
*
((
int
)
i
+
1
);
...
@@ -126,7 +123,6 @@ namespace S04_Projet
...
@@ -126,7 +123,6 @@ namespace S04_Projet
*(
rPixelPtr
+
j
)
=
*(
filePtr
+
opt
.
offset
+
opt
.
padding
*
y
+
j
*
3
+
2
);
*(
rPixelPtr
+
j
)
=
*(
filePtr
+
opt
.
offset
+
opt
.
padding
*
y
+
j
*
3
+
2
);
}
}
}
}
}
#
endregion
#
endregion
#
region
Filter
#
region
Filter
...
@@ -253,5 +249,39 @@ namespace S04_Projet
...
@@ -253,5 +249,39 @@ namespace S04_Projet
else
return
(
byte
)
r
;
else
return
(
byte
)
r
;
}
}
#
endregion
#
endregion
#
region
Save
public
unsafe
void
SaveImage
()
{
Thread
[]
threads
=
new
Thread
[
nbProcessors
];
for
(
int
i
=
0
;
i
<
nbProcessors
;
i
++)
{
threads
[
i
]
=
new
Thread
(
new
ParameterizedThreadStart
(
SaveImageTask
));
threads
[
i
].
Start
(
i
);
}
for
(
int
i
=
0
;
i
<
nbProcessors
;
i
++)
threads
[
i
].
Join
();
}
private
unsafe
void
SaveImageTask
(
object
i
)
{
int
start
=
nbPixel
/
nbProcessors
*
(
int
)
i
;
int
end
=
nbPixel
/
nbProcessors
*
((
int
)
i
+
1
);
int
x
,
y
;
for
(
int
j
=
start
;
j
<
end
;
j
++)
{
x
=
j
%
opt
.
width
;
y
=
j
/
opt
.
width
;
*(
filePtr
+
opt
.
offset
+
opt
.
padding
*
y
+
j
*
3
)
=
*(
bPixelPtr
+
j
);
*(
filePtr
+
opt
.
offset
+
opt
.
padding
*
y
+
j
*
3
+
1
)
=
*(
gPixelPtr
+
j
);
*(
filePtr
+
opt
.
offset
+
opt
.
padding
*
y
+
j
*
3
+
2
)
=
*(
rPixelPtr
+
j
);
}
}
#
endregion
}
}
}
}
S04_Projet/MyImage.cs
View file @
fb9a6f07
...
@@ -112,7 +112,7 @@ namespace S04_Projet
...
@@ -112,7 +112,7 @@ namespace S04_Projet
#
region
Mono
#
region
Mono
if
(!
Program
.
MULTITHREADING
_LOAD
)
if
(!
Program
.
MULTITHREADING
)
{
{
int
y
;
int
y
;
fixed
(
byte
*
filePtr
=
file
,
rPtr
=
rPixels
,
gPtr
=
gPixels
,
bPtr
=
bPixels
)
fixed
(
byte
*
filePtr
=
file
,
rPtr
=
rPixels
,
gPtr
=
gPixels
,
bPtr
=
bPixels
)
...
@@ -181,6 +181,8 @@ namespace S04_Projet
...
@@ -181,6 +181,8 @@ namespace S04_Projet
#
endregion
#
endregion
#
region
Pixel
array
#
region
Pixel
array
if
(!
Program
.
MULTITHREADING
)
{
int
x
;
int
x
;
int
y
;
int
y
;
fixed
(
byte
*
filePtr
=
file
)
fixed
(
byte
*
filePtr
=
file
)
...
@@ -195,6 +197,16 @@ namespace S04_Projet
...
@@ -195,6 +197,16 @@ namespace S04_Projet
*(
filePtr
+
i
*
3
+
opt
.
padding
*
y
+
opt
.
offset
+
2
)
=
rPixels
[
i
];
*(
filePtr
+
i
*
3
+
opt
.
padding
*
y
+
opt
.
offset
+
2
)
=
rPixels
[
i
];
}
}
}
}
}
else
{
fixed
(
byte
*
filePtr
=
file
,
rPtr
=
rPixels
,
gPtr
=
gPixels
,
bPtr
=
bPixels
)
{
MultiThreadedTask
SaveImageTask
=
new
MultiThreadedTask
(
MultiThreadedTask
.
Operation
.
Save
,
opt
,
rPtr
,
gPtr
,
bPtr
,
filePtr
);
SaveImageTask
.
SaveImage
();
}
}
#
endregion
#
endregion
try
try
...
...
S04_Projet/Program.cs
View file @
fb9a6f07
...
@@ -6,7 +6,7 @@ namespace S04_Projet
...
@@ -6,7 +6,7 @@ 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
bool
DEBUG
=
false
;
public
static
bool
DEBUG
=
false
;
...
@@ -83,8 +83,8 @@ namespace S04_Projet
...
@@ -83,8 +83,8 @@ namespace S04_Projet
DEBUG
=
true
;
DEBUG
=
true
;
else
if
(
args
[
i
]
==
"--multithreading"
||
args
[
i
]
==
"-MT"
)
else
if
(
args
[
i
]
==
"--multithreading"
||
args
[
i
]
==
"-MT"
)
MULTITHREADING
=
true
;
MULTITHREADING
=
true
;
else
if
(
args
[
i
]
==
"--multithreadingLoad"
||
args
[
i
]
==
"-MTL"
)
//
else if (args[i] == "--multithreadingLoad" || args[i] == "-MTL")
MULTITHREADING_LOAD
=
true
;
//
MULTITHREADING_LOAD = true;
else
if
(
args
[
i
]
==
"--"
)
;
else
if
(
args
[
i
]
==
"--"
)
;
if
(
DEBUG
)
if
(
DEBUG
)
...
...
S04_Projet/bin/Debug/ImageProcessing.exe
View file @
fb9a6f07
No preview for this file type
S04_Projet/bin/Debug/loadMT
L
.bat
→
S04_Projet/bin/Debug/loadMT.bat
View file @
fb9a6f07
@echo off
@echo off
FOR /L %%i IN (1,1,100) DO (
FOR /L %%i IN (1,1,100) DO (
ECHO %%i
ECHO %%i
ImageProcessing.exe -d -MT
L
-i img\flocon.bmp
ImageProcessing.exe -d -MT -i img\flocon.bmp
)
)
\ No newline at end of file
S04_Projet/bin/Debug/loadSaveMT.bat
0 → 100644
View file @
fb9a6f07
@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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment