-
Notifications
You must be signed in to change notification settings - Fork 0
/
affichage.cpp~
112 lines (93 loc) · 2.15 KB
/
affichage.cpp~
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
#include "affichage.hpp"
using namespace std;
using namespace cv;
int first=0;
void resize(Mat* img,int x,int y){
Mat tmp;
//0 0 gere le redimensionement niquel
resize(*img,tmp,Size(x,y),0,0,INTER_CUBIC);
*img=tmp;
}
void remplir(Mat* img,int* tab,int size, int temp){
int i;
int k;
for(i=0 ; i < size ; i++){
//printf("valeur decale %d\n",tab[i*size+3]);
for(k = 0 ; k < size ; k++){
int value=255-((float)(tab[i*size+k]/(float)temp))*255;
Vec3b& color=img->at<Vec3b>(i,k);
color[0]=value;
color[1]=value;
color[2]=255;
}
}
}
void aff(Mat m,int size){
int i,k;
for(i=0 ; i < size ; i++){
printf("\n");
//printf("valeur decale %d\n",tab[i*size+3]);
for(k = 0 ; k < size ; k++){
Vec3b& color=m.at<Vec3b>(i,k);
printf("color: %d,%d,%d\t",color[0],color[1],color[2]);
}
}
}
void createMat(Mat* img,int size){
Scalar blanc=Scalar(255,255,255);
(*img)=Mat(Size(size,size),CV_8UC3,blanc);
}
void afficher(Mat m){
if(!first){
namedWindow("display",WINDOW_AUTOSIZE);
}
first=1;
imshow( "display", m );
waitKey(0);
}
void afficherFin(Mat m){
namedWindow("Fin",WINDOW_AUTOSIZE);
first=1;
imshow( "Fin", m );
printf("appuyer sur une touche");
waitKey(0);
}
void display(int taille,int* tab,int temperature){
Mat affichage;
createMat(&affichage,taille);
remplir(&affichage,tab,taille,temperature);
//aff(affichage,8);
resize(&affichage,500,500);
afficher(affichage);
}
void displayFin(int taille,int* tab,int temperature){
Mat affichage;
createMat(&affichage,taille);
remplir(&affichage,tab,taille,temperature);
//aff(affichage,8);
resize(&affichage,500,500);
afficherFin(affichage);
}
/*
int main( int argc, const char** argv )
{
//BGR
Scalar blanc=Scalar(255,255,255);
Mat img(Size(900,900),CV_8UC3,blanc);
//int sz[300];
//Mat img(2,sz,CV_8UC(1),Scalar::all(0));
img=blanc;
//resize(&img,300,300);
remplir(img,130,130,170,170);
Mat show;
//cout << img <<endl;
//normalize(img,show,0,1,NORM_MINMAX);
namedWindow("display",WINDOW_AUTOSIZE);
imshow( "display", img );
waitKey(0);
return 0;
}*/