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
|
void test_rapide(){
Mat image(600,600,CV_8UC3);
rgb fond, text;
hsv temp;
Scalar couleur_fond, couleur_text;
for (int y = 0; y < 10; y++){
for (int x = 0; x < 4; x++){
text.r = (rand()%256)/255.0;
text.g = (rand()%256)/255.0;
text.b = (rand()%256)/255.0;
temp = rgb2hsv(text);
temp.h = temp.h + 180; if (temp.h > 360) temp.h -= 360;
if (temp.v < 0.50) temp.v = 1.0 - temp.v;
fond = hsv2rgb(temp);
couleur_fond[0] = fond.b*255.0; couleur_fond[1] = fond.g*255.0; couleur_fond[2] = fond.r*255.0;
couleur_text[0] = text.b*255.0; couleur_text[1] = text.g*255.0; couleur_text[2] = text.r*255.0;
rectangle(image,Point(150*x,60*y),Point(150*(x+1),60*(y+1)),couleur_fond,-1);
putText(image,"Contrast",Point(150*x+5,60*y+35),FONT_HERSHEY_COMPLEX,.9,couleur_text,2);
}
}
imshow("image",image);
waitKey();
imwrite("./contrast.png",image);
} |
Partager