-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdifference.cpp
More file actions
57 lines (40 loc) · 1.17 KB
/
difference.cpp
File metadata and controls
57 lines (40 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include "image_ppm.h"
/*
Avec l’image binaire et l’image dilatées on peut bien voir tous les contours
*/
int main(int argc, char* argv[])
{
char cNomImgLue[250], cNomImgLue2[250], cNomImgEcrite[250];
int nH, nW, nTaille;
if (argc != 4)
{
printf("Usage: ImageIn.pgm dilatation.pgm ImageOut.pgm \n");
exit (1) ;
}
sscanf (argv[1],"%s",cNomImgLue) ;
sscanf (argv[2],"%s",cNomImgLue2) ;
sscanf (argv[3],"%s",cNomImgEcrite);
OCTET *ImgIn, *ImgIn2, *ImgOut;
lire_nb_lignes_colonnes_image_pgm(cNomImgLue, &nH, &nW);
nH = 256;
nW = 256;
nTaille = nH * nW;
allocation_tableau(ImgIn, OCTET, nTaille);
allocation_tableau(ImgIn2, OCTET, nTaille);
lire_image_pgm(cNomImgLue, ImgIn, nH * nW);
lire_image_pgm(cNomImgLue2, ImgIn2, nH * nW);
allocation_tableau(ImgOut, OCTET, nTaille);
for (int i=0; i < nH; i++){
for (int j=0; j < nW; j++){
int x = i*nW+j;
if (ImgIn[x] == ImgIn2[x])
ImgOut[x] = 255;
else
ImgOut[x] = 0;
}
}
ecrire_image_pgm(cNomImgEcrite, ImgOut, nH, nW);
free(ImgIn); free(ImgOut); free(ImgIn2);
return 1;
}