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
0872ae8e
Commit
0872ae8e
authored
6 years ago
by
ariotte
Browse files
Options
Downloads
Patches
Plain Diff
fixed DCT when image size is not a multiple of 16
parent
22f2fb17
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/Algorithms/DCT.cpp
+25
-64
25 additions, 64 deletions
app/Algorithms/DCT.cpp
with
25 additions
and
64 deletions
app/Algorithms/DCT.cpp
+
25
−
64
View file @
0872ae8e
...
...
@@ -21,6 +21,7 @@
#include
"DCT.h"
#include
"../Tools.h"
#include
<Converter.h>
#include
<iostream>
using
namespace
std
;
using
namespace
imagein
;
...
...
@@ -43,25 +44,29 @@ std::string dct16x16(const imagein::Image *img, imagein::Image_t<double> **resIm
* OUVERTURE ET LECTURE DU FICHIER IMAGE ORIGINE
*
*----------------------------------------------------------------------*/
// tab1 = im;
Image_t
<
double
>*
tmpImg
=
Converter
<
Image_t
<
double
>
>::
convert
(
*
img
);
// tabim= new float[size];
// choix = v->choice;
//printf("\n\nMode de codage ? :\n");
//printf(" - par troncature des coefficients (rep=1)\n");
//printf(" - par matrice d'allocation de bits (rep=2)\n");
//printf("Votre choix ? :");
//scanf("%d",&choix);
//PIXEL *p = tab1->get_image_data();
// for(i=0 ; i<nbl ; i++) {
// for(j=0 ; j<nbc ; j++) {
// pixel = tab1->GetPixel( j, i );
// *(tabim+i*nbc+j) = (float)pixel.red;
// }
// }
Image_t
<
double
>*
tmpImg
;
if
(
img
->
getWidth
()
%
16
!=
0
||
img
->
getHeight
()
%
16
!=
0
){
int
addcol
=
0
;
int
addlign
=
0
;
if
(
img
->
getWidth
()
%
16
!=
0
)
addcol
=
16
-
(
img
->
getWidth
()
%
16
);
if
(
img
->
getHeight
()
%
16
!=
0
)
addlign
=
16
-
(
img
->
getHeight
()
%
16
);
tmpImg
=
new
Image_t
<
double
>
(
img
->
getWidth
()
+
addcol
,
img
->
getHeight
()
+
addlign
,
img
->
getNbChannels
());
for
(
unsigned
int
c
=
0
;
c
<
tmpImg
->
getNbChannels
();
c
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
tmpImg
->
getWidth
()
;
i
++
)
{
for
(
unsigned
int
j
=
0
;
j
<
tmpImg
->
getHeight
()
;
j
++
)
{
tmpImg
->
setPixel
(
i
,
j
,
c
,
(
double
)
img
->
getPixel
(
min
(
i
,
img
->
getWidth
()
-
1
),
min
(
j
,
img
->
getHeight
()
-
1
),
c
));
}
}
}
}
else
{
tmpImg
=
Converter
<
Image_t
<
double
>
>::
convert
(
*
img
);
}
/*----------------------------------------------------------------------
*
* CALCUL DES COEFFICIENTS DE LA MATRICE DE TRANSFORMATION
...
...
@@ -69,20 +74,17 @@ std::string dct16x16(const imagein::Image *img, imagein::Image_t<double> **resIm
*----------------------------------------------------------------------*/
double
coef
[
16
];
cosi
(
coef
);
/*----------------------------------------------------------------------
*
* TRANSFORMATION
*
*----------------------------------------------------------------------*/
dct
(
tmpImg
,
coef
);
/*----------------------------------------------------------------------
*
* CODAGE
*
*----------------------------------------------------------------------*/
// printf("\ncodage ...\n");
if
(
truncMode
)
{
returnval
=
tronc
(
tmpImg
,
truncLimit
);
}
...
...
@@ -95,33 +97,6 @@ std::string dct16x16(const imagein::Image *img, imagein::Image_t<double> **resIm
* STOCKAGE DE L'IMAGE TRANSFORMEE DANS UN FICHIER
*
*----------------------------------------------------------------------*/
// max = 0.;
// for(i=0 ; i<nbl ; i++)
// for(j=0 ; j<nbc ; j++)
// {
// a = (float)log(fabs((double)(*(tabim+i*nbc+j))) + 1.);
// if(a > max) max = a;
// }
// //q = (*result)->get_image_data();
// for(i=0 ; i<nbl ; i++)
// for(j=0 ; j<nbc ; j++)
// {
// if( (i%idt)==0 && (j%idt)==0 ) {
// pixel.red = (byte)max;
// pixel.green = (byte)max;
// pixel.blue = (byte)max;
// pixel.alpha = 0;
// (*result)->SetPixel( j, i, pixel );
// }
// else {
// pixel.red = (byte)(log(fabs((double)(*(tabim+i*nbc+j))) + 1.)*255/max + 0.5);
// pixel.green = pixel.red;
// pixel.blue = pixel.red;
// pixel.alpha = 0;
// (*result)->SetPixel( j, i, pixel );
// }
// }
*
resImg
=
new
Image_t
<
double
>
(
*
tmpImg
);
/*----------------------------------------------------------------------
...
...
@@ -136,22 +111,8 @@ std::string dct16x16(const imagein::Image *img, imagein::Image_t<double> **resIm
* STOCKAGE DE L'IMAGE RESULTAT DANS UN FICHIER
*
*----------------------------------------------------------------------*/
// for(i=0 ; i<nbl ; i++)
// for(j=0 ; j<nbc ; j++)
// {
// value = (short)(*(tabim+i*nbc+j) + 0.5);
// if (value > 255) value = 255;
// if (value < 0) value = 0;
// pixel.red = (byte)value;
// pixel.green = (byte)value;
// pixel.blue = (byte)value;
// pixel.alpha = 0;
// (*result_inverse)->SetPixel( j, i, pixel );
// }
*
invImg
=
Converter
<
Image
>::
convertAndRound
(
*
tmpImg
);
delete
tmpImg
;
return
returnval
;
}
...
...
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