Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Projet 3 Traitement Image C
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yann Roberge
Projet 3 Traitement Image C
Commits
2ff55c24
Commit
2ff55c24
authored
3 years ago
by
Yann Roberge
Browse files
Options
Downloads
Patches
Plain Diff
Squelette fonctionnel, aucun traitement d'image
parent
ea631132
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.c
+50
-19
50 additions, 19 deletions
main.c
main.h
+45
-0
45 additions, 0 deletions
main.h
with
95 additions
and
19 deletions
main.c
+
50
−
19
View file @
2ff55c24
...
...
@@ -9,44 +9,75 @@
#include
<stdio.h>
#include
<stdint.h>
#include
<string.h>
// Load raw image to memory. Images should be in
int
loadFrameFromDisk
(
const
uint8_t
*
frameBuffer
,
int
index
)
{
int
loadFrameFromDisk
(
const
PixelRGB8
*
imageRGB
,
int
index
)
{
char
filepath
[
100
];
sprintf
(
filepath
,
"FRAME_IN_DIRECTORY/FRAME_IN_FILENAME%d"
,
index
);
int
fd
=
open
(
filepath
);
return
read
(
fd
,
(
void
*
)
frameBuffer
,
FRAME_BUF_SIZE
);
sprintf
(
filepath
,
"%s%s%d"
,
FRAME_IN_DIRECTORY
,
FRAME_IN_FILENAME
,
index
);
FILE
*
fd
=
fopen
(
filepath
,
"r"
);
int
i
,
status
;
for
(
i
=
0
;
i
<
IMG_AREA
;
i
++
)
{
status
=
fread
((
void
*
)
&
imageRGB
[
i
],
BYTES_PER_PIXEL
,
1
,
fd
);
if
(
status
<
0
)
{
fprintf
(
stderr
,
"Error while reading %s
\n
"
,
filepath
);
fclose
(
fd
);
return
status
;
}
}
fclose
(
fd
);
return
0
;
}
int
writeFrameToDisk
(
const
uint8_t
*
frameBuffer
,
int
index
)
{
int
writeFrameToDisk
(
const
PixelRGB8
*
imageRGB
,
int
index
)
{
char
filepath
[
100
];
sprintf
(
filepath
,
"FRAME_OUT_DIRECTORY/FRAME_OUT_FILENAME%d"
,
index
);
int
fd
=
open
(
filepath
);
return
write
(
fd
,
(
void
*
)
frameBuffer
,
FRAME_BUF_SIZE
);
sprintf
(
filepath
,
"%s%s%d"
,
FRAME_OUT_DIRECTORY
,
FRAME_OUT_FILENAME
,
index
);
FILE
*
fd
=
fopen
(
filepath
,
"w"
);
int
i
,
status
;
for
(
i
=
0
;
i
<
IMG_AREA
;
i
++
)
{
status
=
fwrite
((
void
*
)
&
imageRGB
[
i
],
BYTES_PER_PIXEL
,
1
,
fd
);
if
(
status
<
0
)
{
fprintf
(
stderr
,
"Error while reading %s
\n
"
,
filepath
);
fclose
(
fd
);
return
status
;
}
}
fclose
(
fd
);
return
0
;
}
correctPixelColor
// Convert to HSV
int
correctPixelColor
(
const
PixelRGB8
*
pixel
,
int
deltaHue
,
int
deltaSaturation
,
int
deltaValue
)
{
// TODO: Implémenter
printf
(
"Pixel: %d %d %d
\n
"
,
pixel
->
red
,
pixel
->
green
,
pixel
->
blue
);
// Convert to HSV
// Add corrections
// Add corrections
// Convert back to RGB
// Convert back to RGB
return
0
;
}
// Pass hue, saturation and value (lightness / 2) corrections to args
int
main
(
int
argc
,
char
*
argv
)
{
// Start timing
const
uint8_t
frameBuffer
[
FRAME_BUF_SIZE
];
// TODO: Mesurer le nombre d'image par secondes traitées. Objectif 30fps
const
PixelRGB8
imageRGB
[
IMG_AREA
];
int
i
,
j
;
for
(
i
=
0
;
i
<
N_IMAGES
;
i
++
)
{
loadFrameFromDisk
(
frameBuffer
,
i
);
loadFrameFromDisk
(
imageRGB
,
i
);
// Apply correction to each pixel
and write it back to the frame buffer
for
(
j
=
0
;
j
<
FRAME_BUF_SIZE
;
j
+
=
3
)
{
correctPixelColor
(
frameBuffer
[
j
],
DELTA_HUE
,
DELTA_SATURATION
,
DELTA_VALUE
);
// Apply correction to each pixel
for
(
j
=
0
;
j
<
IMG_AREA
;
j
+
+
)
{
correctPixelColor
(
&
imageRGB
[
j
],
DELTA_HUE
,
DELTA_SATURATION
,
DELTA_VALUE
);
}
writeFrameToDisk
(
frameBuffer
,
i
);
writeFrameToDisk
(
imageRGB
,
i
);
}
// Stop timing
...
...
This diff is collapsed.
Click to expand it.
main.h
+
45
−
0
View file @
2ff55c24
/*********************************************************
* Conversion d'image RGB> HSV > RGB
* Date: 25-Mai-2021
* Auteur: Yann Roberge
*********************************************************/
#include
<stdint.h>
// Image definition
#define N_IMAGES 100
#define IMG_WIDTH 640
#define IMG_HEIGHT 360
#define IMG_AREA (IMG_WIDTH * IMG_HEIGHT)
#define IMG_DEPTH 8 // bits
#define IMG_N_CHANNELS 3 // RGB
#define BYTES_PER_PIXEL (IMG_N_CHANNELS * IMG_DEPTH / 8)
#define FRAME_BUF_SIZE (IMG_AREA * BYTES_PER_PIXEL)
// Files and directories
#define FRAME_IN_DIRECTORY "/run/user/1000/gvfs/sftp:host=odroid,user=nas/media/raid/frames/"
#define FRAME_OUT_DIRECTORY "/run/user/1000/gvfs/sftp:host=odroid,user=nas/media/raid/frames_out/"
#define FRAME_IN_FILENAME "frame"
#define FRAME_OUT_FILENAME "frameout"
// Corrections to apply
#define DELTA_HUE 50
#define DELTA_SATURATION 50
#define DELTA_VALUE 50
// Pixel struct unpacked for processing
typedef
struct
{
uint8_t
red
;
uint8_t
green
;
uint8_t
blue
;
uint8_t
RESERVED
;
}
PixelRGB8
;
// Functions
int
loadFrameFromDisk
(
const
PixelRGB8
*
imageRGB
,
int
index
);
int
writeFrameToDisk
(
const
PixelRGB8
*
imageRGB
,
int
index
);
int
correctPixelColor
(
const
PixelRGB8
*
pixel
,
int
deltaHue
,
int
deltaSaturation
,
int
deltaValue
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment