var pic = getPhoto();# take a frame in rgb32 format
pic = getPhoto();
brick.display().show(pic, total_height, total_width, "rgb32");
script.wait(2000);pic = getPhoto();// take a frame in rgb32 format
var pic = getPhoto();
brick.display().show(pic, total_height, total_width, "rgb32");
script.wait(2000);function grayScale(sPic){
bufPic = [];
for(var i = 0; i < total_height; i++)
for(var j = 0; j < total_width; j++){
var x = i * total_width + j;
var p = sPic[x];
var r = (p & 0xff0000) >> 16; // take the value of the red component
var g = (p & 0xff00) >> 8; // take the value of the green component
var b = (p & 0xff); // take the value of the blue component
p = r * 0.299 + g * 0.587 + b * 0.114; // component Y of YUV
bufPic[x] = p;
}
return bufPic;
}def grayScale(sPic):
bufPic = [];
for i in range(total_height):
for j in range(total_width):
x = i * total_width + j;
p = sPic[x];
r = (p & 0xff0000) >> 16; # take the value of the red component
g = (p & 0xff00) >> 8; # take the value of the green component
b = (p & 0xff); # take the value of the blue component
p = r * 0.299 + g * 0.587 + b * 0.114; # component Y of YUV
bufPic.append(p);
return bufPic;var pic = grayScale(pic);
brick.display().show(pic, total_height, total_width, "grayscale8");
script.wait(2000);pic = grayScale(pic);
brick.display().show(pic, total_height, total_width, "grayscale8");
script.wait(2000);// Binarization - converting the image to black and white
function binarization(treshold, sPic){
bufPic = []
for(var i = 0; i < sPic.length; i++){
bufPic[i] = sPic[i] > treshold ? 255 : 0;
}
return bufPic;
}# Binarization - converting the image to black and white
def binarization(treshold, sPic):
bufPic = []
for i in range(len(sPic)):
bufPic.append(255 if sPic[i] > treshold else 0);
return bufPic;var pic = binarization(80, pic);
brick.display().show(pic, total_height, total_width, "grayscale8");
script.wait(2000);pic = binarization(80, pic);
brick.display().show(pic, total_height, total_width, "grayscale8");
script.wait(2000);