Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tp_integrale_rivier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
nicolas.rivier
tp_integrale_rivier
Commits
b5c764eb
Commit
b5c764eb
authored
2 years ago
by
Og
Browse files
Options
Downloads
Patches
Plain Diff
add convolution signal 1D
parent
7f0b1f29
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
convolution.ods
+0
-0
0 additions, 0 deletions
convolution.ods
main.c
+26
-1
26 additions, 1 deletion
main.c
math_lib.c
+34
-7
34 additions, 7 deletions
math_lib.c
math_lib.h
+3
-0
3 additions, 0 deletions
math_lib.h
with
63 additions
and
8 deletions
convolution.ods
0 → 100644
+
0
−
0
View file @
b5c764eb
File added
This diff is collapsed.
Click to expand it.
main.c
+
26
−
1
View file @
b5c764eb
...
...
@@ -12,6 +12,8 @@ void write_error_graphic_file(const char *filename, const uint32_t size_n[], con
void
Integration_numerique
(
void
);
void
Convolution_filtrage
(
void
);
void
Convolution_test
(
void
);
void
Convolution_1d
(
void
);
void
write_error_graphic_file
(
const
char
*
filename
,
const
uint32_t
size_n
[],
const
double
error_n
[],
const
uint32_t
length_data
)
{
...
...
@@ -79,7 +81,7 @@ void Convolution_filtrage()
normalise_matrix
(
&
res
.
pixels
,
norm_min
,
norm_max
,
res
.
max
);
PrintImagePGM
(
res
,
sdl_name
);
PrintImagePGM
(
res
,
sdl_name
);
pgm_write_to_file
(
&
res
,
output_convolve
);
...
...
@@ -88,11 +90,34 @@ void Convolution_filtrage()
matrix_destroy
(
kernel
);
}
void
Convolution_1d
(
void
)
{
int
PeriodeEchentillonage
=
400
;
double
signal
[
PeriodeEchentillonage
];
double
out
[
PeriodeEchentillonage
];
int
s1_amplitude
=
1
;
int
s1_frequence
=
50
;
int
s2_amplitude
=
10
;
int
s2_frequence
=
5
;
double
pi
=
3
.
14
;
for
(
int
i
=
0
;
i
<
PeriodeEchentillonage
;
i
++
)
{
signal
[
i
]
=
s1_amplitude
*
cos
(
2
*
pi
*
s1_frequence
*
i
)
+
s2_amplitude
*
cos
(
2
*
pi
*
s2_frequence
*
i
);
// printf("%f\n",signal[i]);
}
convolution_signal
(
signal
,
out
,
PeriodeEchentillonage
);
}
int
main
()
{
printf
(
"TP math - Integrales
\n
"
);
Convolution_filtrage
();
Convolution_1d
();
return
EXIT_SUCCESS
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
math_lib.c
+
34
−
7
View file @
b5c764eb
...
...
@@ -269,10 +269,37 @@ double function_for_trapez(double a, uint32_t N, double (*f)(double), double (*O
return
res
;
}
// matrix *convolv_2d(matrix *m1, matrix *kernel)
// {
// matrix *mat = NULL;
// matrix_alloc(mat, m1->col, m1->row);
// matrix_init(mat);
// matrix_print(*mat);
// }
\ No newline at end of file
double
fun1
(
double
*
signal
,
int
index
,
int
N
,
int
len
)
{
double
sum
=
0
.
0
;
if
((
index
+
N
)
<
len
)
{
for
(
int
i
=
index
;
i
<
index
+
N
;
i
++
)
{
sum
+=
signal
[
i
];
}
return
sum
/
N
;
}
return
0
;
}
double
funH
(
double
*
signal
,
int
index
,
int
N
,
int
len
)
{
double
res
=
0
.
0
;
double
pi
=
3
.
14
;
res
=
(
1
/
sqrt
(
2
*
pi
*
N
))
*
exp
((
-
signal
[
index
]
*
signal
[
index
])
/
2
*
N
);
return
res
;
}
void
convolution_signal
(
double
*
signal
,
double
*
out
,
int
len
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
out
[
i
]
=
fun1
(
signal
,
i
,
40
,
len
);
//out[i] = funH(signal,i,40,len);
//printf("%f\n",out[i]);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
math_lib.h
+
3
−
0
View file @
b5c764eb
...
...
@@ -28,5 +28,8 @@ void convolve_matrix(matrix* conv,matrix* orig, const matrix *const kernel, cons
void
normalise_matrix
(
matrix
*
orig
,
int32_t
min
,
int32_t
max
,
int32_t
lumMax
);
// int32_t matrix_min(matrix *orig);
// int32_t matrix_max(matrix* orig);
double
fun1
(
double
*
signal
,
int
index
,
int
N
,
int
len
);
void
convolution_signal
(
double
*
signal
,
double
*
out
,
int
len
);
double
funH
(
double
*
signal
,
int
index
,
int
N
,
int
len
);
#endif
\ No newline at end of file
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