Skip to content
Snippets Groups Projects
Commit 5eb4cd06 authored by jorge.leitemac's avatar jorge.leitemac :juggling_tone5:
Browse files

photomaton ok

parent b35e6edd
No related branches found
No related tags found
No related merge requests found
File added
No preview for this file type
......@@ -7,7 +7,10 @@ void foo(int* elem){
int main(){
pgm p;
pgm_read_from_file(&p, "./img/mandrill.pgm");
//pgm_write_to_file(&p, "./img/mandrill2.pgm");
pgm_write_to_file(&p, "./img/mandrill2.pgm");
pgm ph;
pgm_photomaton(&ph,&p);
pgm_write_to_file(&ph, "./img/photomaton_mandrill.pgm");
//SYM VERTICAL
pgm symV;
......@@ -35,10 +38,14 @@ int main(){
pgm_crop(&crop, &p, 100, 200, 100, 200);
pgm_write_to_file(&crop, "./img/crop_mandrill.pgm");
matrix_destroy(&(p.pixels));
matrix_destroy(&(symH.pixels));
matrix_destroy(&(symV.pixels));
matrix_destroy(&(neg.pixels));
matrix_destroy(&(symC.pixels));
matrix_destroy(&(crop.pixels));
matrix_destroy(&(ph.pixels));
}
\ No newline at end of file
......@@ -177,6 +177,42 @@ pgm_error pgm_crop(pgm *crop, const pgm *const orig,int32_t x0, int32_t x1,int32
return success;
}
pgm_error pgm_photomaton(pgm *photomaton,const pgm *const orig){
pgm_error pgm_photomaton(pgm *photomaton, const pgm *const orig){
int cpt = 0;
int32_t elem;
int32_t valeurs[orig->pixels.m * orig->pixels.n];
//Premier tour de boucle = les lignes impaires,
//deuxieme tour de boucle = les lignes paires
for (int m_pairOuImpair = 0; m_pairOuImpair < 2; m_pairOuImpair++)
{
//Parcourir les lignes
for (int m = m_pairOuImpair; m < orig->pixels.m; m+=2){
//Premier tour de boucle = les colonnes impaires,
//deuxieme tour de boucle = les colonnes paires
for (int n_pairOuImpair = 0; n_pairOuImpair < 2; n_pairOuImpair++)
{
//Parcourir les colonnes
for (int n = n_pairOuImpair; n < orig->pixels.n; n+=2)
{
matrix_get(&elem, orig->pixels, m, n);
valeurs[cpt] = elem;
cpt++;
}
}
}
}
photomaton->max = orig->max;
if(matrix_init_from_array(&photomaton->pixels, orig->pixels.m, orig->pixels.n, valeurs) != OK){
return failure;
}
return success;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment