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
41057c91
Commit
41057c91
authored
10 years ago
by
Antoine Lorence
Browse files
Options
Downloads
Patches
Plain Diff
[MICD] Reindent all the code
parent
97f25d89
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/Operations/MICD.cpp
+77
-78
77 additions, 78 deletions
app/Operations/MICD.cpp
with
77 additions
and
78 deletions
app/Operations/MICD.cpp
+
77
−
78
View file @
41057c91
...
@@ -28,14 +28,14 @@ MICD::MICD()
...
@@ -28,14 +28,14 @@ MICD::MICD()
{
{
long
counter
;
long
counter
;
for
(
counter
=
0
;
counter
<
128
;
counter
++
)
{
for
(
counter
=
0
;
counter
<
128
;
counter
++
)
{
iloiqu
[
counter
]
=
0
;
iloiqu
[
counter
]
=
0
;
}
}
for
(
counter
=
0
;
counter
<
2048
*
20
;
counter
++
)
{
for
(
counter
=
0
;
counter
<
2048
*
20
;
counter
++
)
{
((
int
*
)
itcod
)[
counter
]
=
0
;
((
int
*
)
itcod
)[
counter
]
=
0
;
((
int
*
)
itrco
)[
counter
]
=
0
;
((
int
*
)
itrco
)[
counter
]
=
0
;
}
}
for
(
counter
=
0
;
counter
<
40
;
counter
++
)
{
for
(
counter
=
0
;
counter
<
40
;
counter
++
)
{
((
int
*
)
ktab
)[
counter
]
=
0
;
((
int
*
)
ktab
)[
counter
]
=
0
;
}
}
quantdef
=
NULL
;
quantdef
=
NULL
;
}
}
...
@@ -83,67 +83,67 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, image
...
@@ -83,67 +83,67 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, image
/* codage de l'image */
/* codage de l'image */
for
(
i
=
1
;
i
<
nbl
;
i
++
)
for
(
i
=
1
;
i
<
nbl
;
i
++
)
{
{
for
(
j
=
1
;
j
<
nbc
;
j
++
)
for
(
j
=
1
;
j
<
nbc
;
j
++
)
{
{
if
(
rep
==
PX_EQ_A
)
{
if
(
rep
==
PX_EQ_A
)
{
temp_p
=
reconstructed_image
->
getPixelAt
(
j
-
1
,
i
);
temp_p
=
reconstructed_image
->
getPixelAt
(
j
-
1
,
i
);
pred
=
temp_p
;
pred
=
temp_p
;
}
}
else
if
(
rep
==
PX_EQ_B
)
{
else
if
(
rep
==
PX_EQ_B
)
{
temp_p
=
reconstructed_image
->
getPixelAt
(
j
,
i
-
1
);
temp_p
=
reconstructed_image
->
getPixelAt
(
j
,
i
-
1
);
pred
=
temp_p
;
pred
=
temp_p
;
}
}
else
if
(
rep
==
PX_EQ_APC
)
{
else
if
(
rep
==
PX_EQ_APC
)
{
temp_p
=
reconstructed_image
->
getPixelAt
(
j
-
1
,
i
);
temp_p
=
reconstructed_image
->
getPixelAt
(
j
-
1
,
i
);
pred
=
(
int
)
temp_p
;
pred
=
(
int
)
temp_p
;
temp_p
=
reconstructed_image
->
getPixelAt
(
j
,
i
-
1
);
temp_p
=
reconstructed_image
->
getPixelAt
(
j
,
i
-
1
);
pred
=
(
pred
+
(
int
)
temp_p
)
/
2
;
pred
=
(
pred
+
(
int
)
temp_p
)
/
2
;
}
}
else
if
(
rep
==
PX_EQ_Q
)
{
else
if
(
rep
==
PX_EQ_Q
)
{
/*
/*
Modified Graham's Algorithm:
Modified Graham's Algorithm:
if |B-C| - Q <= |B-A| <= |B-C| + Q
if |B-C| - Q <= |B-A| <= |B-C| + Q
P(X) = (A+C)/2
P(X) = (A+C)/2
else
else
if |B-A| > |B-C|
if |B-A| > |B-C|
P(X) = A
P(X) = A
else
else
P(X) = C
P(X) = C
*/
*/
float
A
=
im
->
getPixelAt
(
j
-
1
,
i
);
float
A
=
im
->
getPixelAt
(
j
-
1
,
i
);
float
B
=
im
->
getPixelAt
(
j
-
1
,
i
-
1
);
float
B
=
im
->
getPixelAt
(
j
-
1
,
i
-
1
);
float
C
=
im
->
getPixelAt
(
j
,
i
-
1
);
float
C
=
im
->
getPixelAt
(
j
,
i
-
1
);
if
(
((
fabs
(
B
-
C
)
-
Q
)
<=
fabs
(
B
-
A
))
&&
if
(
((
fabs
(
B
-
C
)
-
Q
)
<=
fabs
(
B
-
A
))
&&
(
fabs
(
B
-
A
)
<=
(
fabs
(
B
-
C
)
+
Q
))
)
{
(
fabs
(
B
-
A
)
<=
(
fabs
(
B
-
C
)
+
Q
))
)
{
pred
=
(
uint8_t
)((
A
+
C
)
/
2
);
pred
=
(
uint8_t
)((
A
+
C
)
/
2
);
}
}
else
{
else
{
if
(
fabs
(
B
-
A
)
>
fabs
(
B
-
C
)
)
{
if
(
fabs
(
B
-
A
)
>
fabs
(
B
-
C
)
)
{
pred
=
(
uint8_t
)
A
;
pred
=
(
uint8_t
)
A
;
}
}
else
{
else
{
pred
=
(
uint8_t
)
C
;
pred
=
(
uint8_t
)
C
;
}
}
}
}
}
}
temp_p
=
reconstructed_image
->
getPixelAt
(
j
,
i
);
temp_p
=
reconstructed_image
->
getPixelAt
(
j
,
i
);
ier
=
(
int
)
temp_p
-
pred
;
ier
=
(
int
)
temp_p
-
pred
;
codec
(
0
,
ier
,
&
icode
,
&
ireco
);
codec
(
0
,
ier
,
&
icode
,
&
ireco
);
pi
[
ier
+
255
]
++
;
/* proba associe l'erreur de prdiction */
pi
[
ier
+
255
]
++
;
/* proba associe l'erreur de prdiction */
nbpt
++
;
nbpt
++
;
int
tempvalue
;
int
tempvalue
;
tempvalue
=
ier
+
128
;
tempvalue
=
ier
+
128
;
po
=
tempvalue
;
po
=
tempvalue
;
error_prediction_image
->
setPixelAt
(
j
,
i
,
po
);
error_prediction_image
->
setPixelAt
(
j
,
i
,
po
);
tempvalue
=
pred
+
ireco
;
tempvalue
=
pred
+
ireco
;
if
(
tempvalue
>
255
)
tempvalue
=
255
;
if
(
tempvalue
>
255
)
tempvalue
=
255
;
if
(
tempvalue
<
0
)
tempvalue
=
0
;
if
(
tempvalue
<
0
)
tempvalue
=
0
;
po
=
tempvalue
;
po
=
tempvalue
;
reconstructed_image
->
setPixelAt
(
j
,
i
,
po
);
reconstructed_image
->
setPixelAt
(
j
,
i
,
po
);
}
}
}
}
/* calcul de l'entropie de l'image d'erreur de prdiction */
/* calcul de l'entropie de l'image d'erreur de prdiction */
for
(
i
=
0
;
i
<
512
;
i
++
)
for
(
i
=
0
;
i
<
512
;
i
++
)
...
@@ -160,7 +160,6 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, image
...
@@ -160,7 +160,6 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, image
returnval
=
returnval
+
"
\n
"
;
returnval
=
returnval
+
"
\n
"
;
returnval
=
returnval
+
print_iloiqu
();
returnval
=
returnval
+
print_iloiqu
();
/* libration de la mmoire alloue */
/* libration de la mmoire alloue */
*
err_image
=
error_prediction_image
;
*
err_image
=
error_prediction_image
;
*
recons_image
=
reconstructed_image
;
*
recons_image
=
reconstructed_image
;
...
@@ -168,7 +167,7 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, image
...
@@ -168,7 +167,7 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, image
}
}
void
MICD
::
codlq
(
int
m
)
{
void
MICD
::
codlq
(
int
m
)
{
int
n
,
nar
,
nk
,
i
,
j
;
int
n
,
nar
,
nk
,
i
,
j
;
n
=
iloiqu
[
0
];
n
=
iloiqu
[
0
];
ktab
[
0
][
m
]
=
iloiqu
[
1
];
ktab
[
0
][
m
]
=
iloiqu
[
1
];
...
@@ -176,10 +175,10 @@ void MICD::codlq(int m) {
...
@@ -176,10 +175,10 @@ void MICD::codlq(int m) {
j
=
-
1
;
j
=
-
1
;
for
(
i
=
0
;
i
<
n
-
1
;
i
++
)
for
(
i
=
0
;
i
<
n
-
1
;
i
++
)
{
{
nk
=
1
+
nar
-
iloiqu
[
2
*
i
+
1
];
nk
=
1
+
nar
-
iloiqu
[
2
*
i
+
1
];
do
{
j
++
;
itcod
[
j
][
m
]
=
i
;
nk
++
;}
while
(
nk
<=
0
);
do
{
j
++
;
itcod
[
j
][
m
]
=
i
;
nk
++
;}
while
(
nk
<=
0
);
nar
=
iloiqu
[
2
*
i
+
1
];
nar
=
iloiqu
[
2
*
i
+
1
];
itrco
[
i
][
m
]
=
iloiqu
[
2
*
i
+
2
];
itrco
[
i
][
m
]
=
iloiqu
[
2
*
i
+
2
];
}
}
itcod
[
j
+
1
][
m
]
=
i
;
itcod
[
j
+
1
][
m
]
=
i
;
itrco
[
i
][
m
]
=
iloiqu
[
2
*
i
+
2
];
itrco
[
i
][
m
]
=
iloiqu
[
2
*
i
+
2
];
...
@@ -187,31 +186,31 @@ void MICD::codlq(int m) {
...
@@ -187,31 +186,31 @@ void MICD::codlq(int m) {
}
}
void
MICD
::
codec
(
int
nlq
,
int
ier
,
int
*
icode
,
int
*
ireco
)
{
void
MICD
::
codec
(
int
nlq
,
int
ier
,
int
*
icode
,
int
*
ireco
)
{
int
m
,
ip
,
iep
,
ierp
,
n
,
l
;
int
m
,
ip
,
iep
,
ierp
,
n
,
l
;
m
=
nlq
;
m
=
nlq
;
ip
=
ktab
[
0
][
m
];
ip
=
ktab
[
0
][
m
];
ierp
=
ier
-
ip
;
ierp
=
ier
-
ip
;
if
(
ierp
>
0
)
if
(
ierp
>
0
)
{
{
ip
=
ktab
[
1
][
m
];
ip
=
ktab
[
1
][
m
];
iep
=
ier
-
ip
;
iep
=
ier
-
ip
;
if
(
iep
<
0
)
if
(
iep
<
0
)
n
=
ier
-
ktab
[
0
][
m
];
n
=
ier
-
ktab
[
0
][
m
];
else
else
n
=
ktab
[
1
][
m
]
-
ktab
[
0
][
m
];
n
=
ktab
[
1
][
m
]
-
ktab
[
0
][
m
];
*
icode
=
itcod
[
n
][
m
];
*
icode
=
itcod
[
n
][
m
];
l
=
*
icode
;
l
=
*
icode
;
*
ireco
=
itrco
[
l
][
m
];
*
ireco
=
itrco
[
l
][
m
];
}
}
else
else
{
{
*
icode
=
itcod
[
0
][
m
];
*
icode
=
itcod
[
0
][
m
];
*
ireco
=
itrco
[
0
][
m
];
*
ireco
=
itrco
[
0
][
m
];
}
}
}
}
void
MICD
::
set_levels
()
{
void
MICD
::
set_levels
()
{
// Fills in iloiqu with the specified values
// Fills in iloiqu with the specified values
if
(
quantdef
->
size
-
1
>
32
||
quantdef
->
size
-
1
<
1
)
{
if
(
quantdef
->
size
-
1
>
32
||
quantdef
->
size
-
1
<
1
)
{
char
buffer
[
255
];
char
buffer
[
255
];
sprintf
(
buffer
,
"Error in MICD::set_levels:
\n
quantdef->GetNumThresholds() = %d"
,
quantdef
->
size
-
1
);
sprintf
(
buffer
,
"Error in MICD::set_levels:
\n
quantdef->GetNumThresholds() = %d"
,
quantdef
->
size
-
1
);
...
@@ -228,13 +227,13 @@ void MICD::set_levels() {
...
@@ -228,13 +227,13 @@ void MICD::set_levels() {
}
}
string
MICD
::
print_iloiqu
()
{
string
MICD
::
print_iloiqu
()
{
string
returnval
;
string
returnval
;
returnval
=
"seuils de dcision --------------- niveaux de reconstruction
\n
"
;
returnval
=
"seuils de dcision --------------- niveaux de reconstruction
\n
"
;
int
counter
;
int
counter
;
char
buffer
[
100
];
char
buffer
[
100
];
for
(
counter
=
1
;
counter
<=
iloiqu
[
0
]
*
2
-
1
;
counter
++
)
{
for
(
counter
=
1
;
counter
<=
iloiqu
[
0
]
*
2
-
1
;
counter
++
)
{
if
(
!
(
counter
&
1
==
1
)
)
{
if
(
!
(
counter
&
1
==
1
)
)
{
sprintf
(
buffer
,
" %3d
\n
"
,
iloiqu
[
counter
]
);
sprintf
(
buffer
,
" %3d
\n
"
,
iloiqu
[
counter
]
);
returnval
=
returnval
+
buffer
;
returnval
=
returnval
+
buffer
;
sprintf
(
buffer
,
" %3d ---------------------------------------------
\n
"
,
iloiqu
[
counter
-
1
]
);
sprintf
(
buffer
,
" %3d ---------------------------------------------
\n
"
,
iloiqu
[
counter
-
1
]
);
returnval
=
returnval
+
buffer
;
returnval
=
returnval
+
buffer
;
...
...
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