Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ImageINSA_Tanguy
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
Tanguy.Raufflet
ImageINSA_Tanguy
Commits
95156633
Commit
95156633
authored
7 years ago
by
Bigot Quentin
Browse files
Options
Downloads
Patches
Plain Diff
added error prediction image entropy calculation to DPCM
parent
48c802d4
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
app/Operations/DPCM.cpp
+23
-10
23 additions, 10 deletions
app/Operations/DPCM.cpp
app/Operations/Transforms.cpp
+5
-3
5 additions, 3 deletions
app/Operations/Transforms.cpp
with
28 additions
and
13 deletions
app/Operations/DPCM.cpp
+
23
−
10
View file @
95156633
...
@@ -47,15 +47,16 @@ DPCM::~DPCM()
...
@@ -47,15 +47,16 @@ DPCM::~DPCM()
}
}
string
DPCM
::
execute
(
const
GrayscaleImage
*
im
,
Prediction
prediction_alg
,
imagein
::
ImageDouble
**
quant_err_image
,
imagein
::
ImageDouble
**
new_err_image
,
Image
**
recons_image
,
Image
**
pred_image
,
double
Q
)
{
string
DPCM
::
execute
(
const
GrayscaleImage
*
im
,
Prediction
prediction_alg
,
imagein
::
ImageDouble
**
quant_err_image
,
imagein
::
ImageDouble
**
new_err_image
,
Image
**
recons_image
,
Image
**
pred_image
,
double
Q
)
{
char
buffer
[
255
];
char
buffer
[
255
]
,
buffer2
[
255
]
;
if
(
quantdef
==
NULL
)
{
if
(
quantdef
==
NULL
)
{
throw
"Error in DPCM::execute:
\n
quantdef = NULL"
;
throw
"Error in DPCM::execute:
\n
quantdef = NULL"
;
}
}
string
returnval
;
string
returnval
;
int
imgHeight
,
imgWidth
,
pred
,
ier
,
ireco
,
icode
;
int
imgHeight
,
imgWidth
,
pred
,
ier
,
ierq
,
ireco
,
icode
;
float
pi
[
512
],
nbpt
=
0
;
float
pi
[
512
],
piq
[
512
],
nbpt
=
0
;
double
h
=
0.
;
double
h
=
0.
;
double
hq
=
0.
;
imgHeight
=
im
->
getHeight
();
imgHeight
=
im
->
getHeight
();
imgWidth
=
im
->
getWidth
();
imgWidth
=
im
->
getWidth
();
...
@@ -80,7 +81,7 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
...
@@ -80,7 +81,7 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
/* mise a 0 du tableau des probas servant pour le calcul de
/* mise a 0 du tableau des probas servant pour le calcul de
l'entropie de l'erreur de prdiction */
l'entropie de l'erreur de prdiction */
for
(
int
i
=
0
;
i
<
512
;
i
++
)
pi
[
i
]
=
0.
;
for
(
int
i
=
0
;
i
<
512
;
i
++
)
{
pi
[
i
]
=
0.
;
piq
[
i
]
=
0
;}
/* codage de l'image */
/* codage de l'image */
for
(
int
i
=
1
;
i
<
imgHeight
;
i
++
)
for
(
int
i
=
1
;
i
<
imgHeight
;
i
++
)
...
@@ -140,37 +141,49 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
...
@@ -140,37 +141,49 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
prediction_image
->
setPixelAt
(
j
,
i
,
pred
);
prediction_image
->
setPixelAt
(
j
,
i
,
pred
);
depth_default_t
thePixel
=
reconstructed_image
->
getPixelAt
(
j
,
i
);
depth_default_t
thePixel
=
reconstructed_image
->
getPixelAt
(
j
,
i
);
//erreur de prediction
ier
=
thePixel
-
pred
;
ier
=
thePixel
-
pred
;
new_error_prediction_image
->
setPixelAt
(
j
,
i
,
ier
);
new_error_prediction_image
->
setPixelAt
(
j
,
i
,
ier
);
ier
=
quantdef
->
valueOf
(
ier
);
/* proba associe a l'erreur de prediction */
codec
(
0
,
ier
,
&
icode
,
&
ireco
);
//quantification erreur de prediction
ierq
=
quantdef
->
valueOf
(
ier
);
pi
[
ier
+
255
]
++
;
/* proba associe a l'erreur de prdiction */
codec
(
0
,
ierq
,
&
icode
,
&
ireco
);
//(QB) action ? on suppose codage/decodage sans perte : ireco = ierq
pi
[
ier
+
255
]
++
;
piq
[
ierq
+
255
]
++
;
/* proba associe a l'erreur de prediction */
nbpt
++
;
nbpt
++
;
//TODO : changer le nom de l'image en quantized_error_prediction_image (done)
quantized_error_prediction_image
->
setPixelAt
(
j
,
i
,
ierq
);
quantized_error_prediction_image
->
setPixelAt
(
j
,
i
,
ier
);
// valeur reconstruite
int
tempvalue
=
pred
+
ireco
;
int
tempvalue
=
pred
+
ireco
;
// Crop the value in [0,255]
// Crop the value in [0,255]
reconstructed_image
->
setPixelAt
(
j
,
i
,
tempvalue
>
255
?
255
:
tempvalue
<
0
?
0
:
tempvalue
);
reconstructed_image
->
setPixelAt
(
j
,
i
,
tempvalue
>
255
?
255
:
tempvalue
<
0
?
0
:
tempvalue
);
}
}
}
}
/* calcul de l'entropie de l'image d'erreur de prediction */
/* calcul de l'entropie de l'image d'erreur de prediction
quantifiee
*/
for
(
int
i
=
0
;
i
<
512
;
i
++
)
for
(
int
i
=
0
;
i
<
512
;
i
++
)
{
{
if
(
pi
[
i
]
!=
0
)
{
if
(
pi
[
i
]
!=
0
)
{
pi
[
i
]
/=
nbpt
;
pi
[
i
]
/=
nbpt
;
h
-=
(
double
)
pi
[
i
]
*
log
((
double
)
pi
[
i
])
/
log
((
double
)
2.0
);
h
-=
(
double
)
pi
[
i
]
*
log
((
double
)
pi
[
i
])
/
log
((
double
)
2.0
);
}
}
if
(
piq
[
i
]
!=
0
)
{
piq
[
i
]
/=
nbpt
;
hq
-=
(
double
)
piq
[
i
]
*
log
((
double
)
piq
[
i
])
/
log
((
double
)
2.0
);
}
}
}
/* affichage des rsultats */
/* affichage des rsultats */
sprintf
(
buffer
,
"
\n
L'entropie de l'image d'erreur de prediction vaut : %lf
\n
"
,
h
);
sprintf
(
buffer
,
"
\n
L'entropie de l'image d'erreur de prediction vaut : %lf
\n
"
,
h
);
sprintf
(
buffer2
,
"
\n
L'entropie de l'image d'erreur de prediction quantifiee vaut : %lf
\n
"
,
hq
);
returnval
=
returnval
+
buffer
;
returnval
=
returnval
+
buffer
;
returnval
=
returnval
+
"
\n
"
;
returnval
=
returnval
+
"
\n
"
;
returnval
=
returnval
+
buffer2
;
returnval
=
returnval
+
"
\n
"
;
returnval
=
returnval
+
print_iloiqu
();
returnval
=
returnval
+
print_iloiqu
();
/* libration de la mmoire alloue */
/* libration de la mmoire alloue */
...
...
This diff is collapsed.
Click to expand it.
app/Operations/Transforms.cpp
+
5
−
3
View file @
95156633
...
@@ -117,11 +117,13 @@ Image_t<double>* Transforms::hough2(const Image *image, double angleStep, double
...
@@ -117,11 +117,13 @@ Image_t<double>* Transforms::hough2(const Image *image, double angleStep, double
{
{
if
(
image
->
getPixelAt
(
i
,
j
,
c
)
==
255
)
if
(
image
->
getPixelAt
(
i
,
j
,
c
)
==
255
)
{
{
//TODO : parcourir entre -180 et 90
for
(
double
te
=
0
;
te
<
180
;
te
+=
angleStep
)
// on parcourt la matrice
for
(
double
te
=
0
;
te
<
180
;
te
+=
angleStep
)
// on parcourt la matrice
{
{
const
double
coste
=
cos
(
te
*
pi
/
180.
);
//const double coste = cos(te * pi / 180.);
double
sinte
=
sin
(
te
*
pi
/
180.
);
const
double
coste
=
1
;
//double sinte = sin(te * pi / 180.);
double
sinte
=
1
;
// for(double ro = 0; ro < imageDiag; ro += rhoStep)
// for(double ro = 0; ro < imageDiag; ro += rhoStep)
// {
// {
...
...
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