-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.q
61 lines (35 loc) · 1.42 KB
/
test.q
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
\l qCam.q
width:640;
height:480;
pixelformat:`RGB3;
//Start the camera
camera:startcamera[width;height;pixelformat];
//Create the prototype dictionary
colourPic:`encoding`width`height`maxval`data!(`P6;width;height;255;());
//Grab a frame from the camera
colourPic[`data]:snap[camera;3*colourPic[`width]*colourPic[`height]];
saveppm[`:test/1_colour;colourPic];
greyPic:greyscale[colourPic];
savepgm[`:test/2_grey;greyPic];
rotatedPic:rotatePic[greyPic;2];
savepgm[`:test/3_rotate;rotatedPic];
croppedPic:crop[greyPic;greyPic[`height]-1;greyPic[`width]-1;`int$-1*greyPic[`height]%2;`int$-1*greyPic[`width]%2];
savepgm[`:test/4_crop;croppedPic];
zoomedPic:zoom[greyPic;100];
savepgm[`:test/5_zoom;zoomedPic];
resizedPic:resize[greyPic;2];
savepgm[`:test/6_resize;resizedPic];
//Define kernel to test convolute function
kernel:((0 1 0f);(1 -4 1f);(0 1 0f));
//Apply convolution function
convolutedPic:convolute[greyPic;kernel];
savepgm[`:test/7_convolute;@[;`data;`byte$] convolutedPic];
//Adjust values so that there are no negative values
normalisedPic:normalise[convolutedPic;0;255];
savepgm[`:test/8_normalise;@[;`data;`byte$] normalisedPic];
textPic:makePGM draw arialBold "This is a test";
savepgm[`:test/9_text;@[;`data;`byte$] textPic];
savepgm[`:test/10_overlay] overlay[textPic;greyPic;50;floor %[;2] greyPic[`width]-textPic[`width]];
\cd test
{system"convert ",x," ",(first "." vs x),".jpg"} each string key `:.;
exit 0