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
a0002f0a
Commit
a0002f0a
authored
7 years ago
by
Bigot Quentin
Browse files
Options
Downloads
Patches
Plain Diff
modify DPCM variables name and add coding error image
parent
ef294b42
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/Operations/DPCM.cpp
+35
-17
35 additions, 17 deletions
app/Operations/DPCM.cpp
app/Operations/DPCM.h
+1
-1
1 addition, 1 deletion
app/Operations/DPCM.h
app/Operations/DPCMEncodingOp.cpp
+5
-3
5 additions, 3 deletions
app/Operations/DPCMEncodingOp.cpp
with
41 additions
and
21 deletions
app/Operations/DPCM.cpp
+
35
−
17
View file @
a0002f0a
...
@@ -46,13 +46,19 @@ DPCM::~DPCM()
...
@@ -46,13 +46,19 @@ 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
**
err_image
,
Image
**
recons_image
,
Image
**
pred_image
,
ImageDouble
**
coding_err_image
,
double
Q
)
{
char
buffer
[
255
],
buffer2
[
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
,
ierq
,
ireco
,
icode
;
int
imgHeight
,
imgWidth
;
int
pred
;
int
pred_err
;
// prediction error
int
quant_pred_err
;
// quantized prediction error
int
reco
;
// reconstructed value
int
code
;
// code
int
coding_err
;
// erreur de codage
float
pi
[
512
],
piq
[
512
],
nbpt
=
0
;
float
pi
[
512
],
piq
[
512
],
nbpt
=
0
;
double
h
=
0.
;
double
h
=
0.
;
...
@@ -66,16 +72,17 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
...
@@ -66,16 +72,17 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
codlq
(
0
);
codlq
(
0
);
/* allocation mmoire pour l'image d'erreur de prdiction */
/* allocation mmoire pour l'image d'erreur de prdiction */
ImageDouble
*
quantized_error_prediction_image
=
new
ImageDouble
(
imgWidth
,
imgHeight
,
1
);
ImageDouble
*
quantized_predction_error_image
=
new
ImageDouble
(
imgWidth
,
imgHeight
,
1
);
// renommer quantized_predction_error_image
ImageDouble
*
new_error_prediction_image
=
new
ImageDouble
(
imgWidth
,
imgHeight
,
1
);
ImageDouble
*
predction_error_image
=
new
ImageDouble
(
imgWidth
,
imgHeight
,
1
);
// renommer predction_error_image
ImageDouble
*
coding_error_image
=
new
ImageDouble
(
imgWidth
,
imgHeight
,
1
);
Image
*
reconstructed_image
=
new
GrayscaleImage
(
*
im
);
Image
*
reconstructed_image
=
new
GrayscaleImage
(
*
im
);
Image
*
prediction_image
=
new
GrayscaleImage
(
*
im
);
Image
*
prediction_image
=
new
GrayscaleImage
(
*
im
);
// Init the error images with 0 values
// Init the error images with 0 values
for
(
int
i
=
0
;
i
<
imgHeight
;
i
++
)
{
for
(
int
i
=
0
;
i
<
imgHeight
;
i
++
)
{
for
(
int
j
=
0
;
j
<
imgWidth
;
j
++
)
{
for
(
int
j
=
0
;
j
<
imgWidth
;
j
++
)
{
quantized_
error_
pred
i
ction_image
->
setPixelAt
(
j
,
i
,
0
);
quantized_predction_
error_
image
->
setPixelAt
(
j
,
i
,
0
);
new_error_
pred
i
ction_image
->
setPixelAt
(
j
,
i
,
0
);
predction_
error_
image
->
setPixelAt
(
j
,
i
,
0
);
}
}
}
}
...
@@ -138,29 +145,39 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
...
@@ -138,29 +145,39 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
break
;
break
;
}
}
//image de prediction pour affichage
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
//erreur de prediction
ie
r
=
thePixel
-
pred
;
pred_er
r
=
thePixel
-
pred
;
new_error_
pred
i
ction_image
->
setPixelAt
(
j
,
i
,
ie
r
);
predction_
error_
image
->
setPixelAt
(
j
,
i
,
pred_er
r
);
/* proba associe a l'erreur de prediction */
/* proba associe a l'erreur de prediction */
depth_default_t
pixImg
=
im
->
getPixelAt
(
j
,
i
);
//quantification erreur de prediction
//quantification erreur de prediction
ierq
=
quantdef
->
valueOf
(
ie
r
);
quant_pred_err
=
quantdef
->
valueOf
(
pred_er
r
);
codec
(
0
,
i
er
q
,
&
i
code
,
&
i
reco
);
//
(QB)
action ? on suppose codage/decodage sans perte :
i
reco =
i
er
q
codec
(
0
,
quant_pred_
er
r
,
&
code
,
&
reco
);
//action ? on suppose codage/decodage sans perte : reco =
quant_pred_
er
r
pi
[
ie
r
+
255
]
++
;
pi
[
pred_er
r
+
255
]
++
;
piq
[
ierq
+
255
]
++
;
/* proba associe a l'erreur de prediction */
piq
[
quant_pred_err
+
255
]
++
;
/* proba associe a l'erreur de prediction */
nbpt
++
;
nbpt
++
;
quantized_
error_
pred
i
ction_image
->
setPixelAt
(
j
,
i
,
ierq
);
quantized_predction_
error_
image
->
setPixelAt
(
j
,
i
,
quant_pred_err
);
// valeur reconstruite
// valeur reconstruite
int
tempvalue
=
pred
+
ireco
;
int
tempvalue
=
pred
+
reco
;
//int tempvalue = pred + quant_pred_err;
// 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
);
depth_default_t
reconstructedPix
=
reconstructed_image
->
getPixelAt
(
j
,
i
);
//calcul de l'erreur de codage
coding_err
=
pixImg
-
reconstructedPix
;
//construction de l'image d'erreur de codage
coding_error_image
->
setPixelAt
(
j
,
i
,(
coding_err
));
}
}
}
}
...
@@ -187,10 +204,11 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
...
@@ -187,10 +204,11 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
returnval
=
returnval
+
print_iloiqu
();
returnval
=
returnval
+
print_iloiqu
();
/* libration de la mmoire alloue */
/* libration de la mmoire alloue */
*
quant_err_image
=
quantized_
error_
pred
i
ction_image
;
*
quant_err_image
=
quantized_predction_
error_
image
;
*
new_
err_image
=
new_error_
pred
i
ction_image
;
*
err_image
=
predction_
error_
image
;
*
recons_image
=
reconstructed_image
;
*
recons_image
=
reconstructed_image
;
*
pred_image
=
prediction_image
;
*
pred_image
=
prediction_image
;
*
coding_err_image
=
coding_error_image
;
return
returnval
;
return
returnval
;
}
}
...
...
This diff is collapsed.
Click to expand it.
app/Operations/DPCM.h
+
1
−
1
View file @
a0002f0a
...
@@ -30,7 +30,7 @@ public:
...
@@ -30,7 +30,7 @@ public:
DPCM
();
DPCM
();
enum
Prediction
{
PX_EQ_A
,
PX_EQ_B
,
PX_EQ_APC
,
PX_EQ_Q
};
enum
Prediction
{
PX_EQ_A
,
PX_EQ_B
,
PX_EQ_APC
,
PX_EQ_Q
};
virtual
~
DPCM
();
virtual
~
DPCM
();
std
::
string
execute
(
const
imagein
::
GrayscaleImage
*
im
,
Prediction
prediction_alg
,
imagein
::
ImageDouble
**
quant_err_image
,
imagein
::
ImageDouble
**
new_err_image
,
imagein
::
Image
**
recons_image
,
imagein
::
Image
**
pred_image
,
double
Q
=
0
);
std
::
string
execute
(
const
imagein
::
GrayscaleImage
*
im
,
Prediction
prediction_alg
,
imagein
::
ImageDouble
**
quant_err_image
,
imagein
::
ImageDouble
**
new_err_image
,
imagein
::
Image
**
recons_image
,
imagein
::
Image
**
pred_image
,
imagein
::
ImageDouble
**
coding_err_image
,
double
Q
=
0
);
void
setQuantification
(
Quantification
*
tquantdef
);
void
setQuantification
(
Quantification
*
tquantdef
);
private
:
private
:
std
::
string
print_iloiqu
();
std
::
string
print_iloiqu
();
...
...
This diff is collapsed.
Click to expand it.
app/Operations/DPCMEncodingOp.cpp
+
5
−
3
View file @
a0002f0a
...
@@ -59,10 +59,12 @@ void DPCMEncodingOp::operator()(const imagein::Image* img, const std::map<const
...
@@ -59,10 +59,12 @@ void DPCMEncodingOp::operator()(const imagein::Image* img, const std::map<const
Image
*
predictionImage
;
Image
*
predictionImage
;
ImageDouble
*
quant_errorImage
;
ImageDouble
*
quant_errorImage
;
ImageDouble
*
errorImage
;
ImageDouble
*
errorImage
;
string
s
=
micd
.
execute
(
image
,
dialog
->
getPrediction
(),
&
quant_errorImage
,
&
errorImage
,
&
reconstructedImage
,
&
predictionImage
,
dialog
->
getQ
());
ImageDouble
*
coding_error_image
;
string
s
=
micd
.
execute
(
image
,
dialog
->
getPrediction
(),
&
quant_errorImage
,
&
errorImage
,
&
reconstructedImage
,
&
predictionImage
,
&
coding_error_image
,
dialog
->
getQ
());
outText
(
s
);
outText
(
s
);
outDoubleImage
(
errorImage
,
qApp
->
translate
(
"DPCM"
,
"
E
rror image"
).
toStdString
(),
true
,
true
,
0.1
,
false
);
outDoubleImage
(
errorImage
,
qApp
->
translate
(
"DPCM"
,
"
Prediction e
rror image"
).
toStdString
(),
true
,
true
,
0.1
,
false
);
outDoubleImage
(
quant_errorImage
,
qApp
->
translate
(
"DPCM"
,
"Quantized error image"
).
toStdString
(),
true
,
true
,
0.1
,
false
);
outDoubleImage
(
quant_errorImage
,
qApp
->
translate
(
"DPCM"
,
"Quantized
prediction
error image"
).
toStdString
(),
true
,
true
,
0.1
,
false
);
outImage
(
predictionImage
,
qApp
->
translate
(
"DPCM"
,
"Prediction image"
).
toStdString
());
outImage
(
predictionImage
,
qApp
->
translate
(
"DPCM"
,
"Prediction image"
).
toStdString
());
outImage
(
reconstructedImage
,
qApp
->
translate
(
"DPCM"
,
"Reconstructed image"
).
toStdString
());
outImage
(
reconstructedImage
,
qApp
->
translate
(
"DPCM"
,
"Reconstructed image"
).
toStdString
());
outDoubleImage
(
coding_error_image
,
qApp
->
translate
(
"DPCM"
,
"Coding error image"
).
toStdString
(),
true
,
true
,
0.1
,
false
);
}
}
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