Converting pixel in binary values... clockwise!
in
Programming Questions
•
2 years ago
Hi all, I am new to processing an I need help...
First of all I have to say that I am italian and I am sorry for my poor english so I hope you will understand my question.
I should convert the pixels of a grayscale image (I use only white and black, not intermediate colours) to binary numbers, 0 if the pixel is white and 1 if it is black and I should put these values in some array. Suppose that the image is divided into rows and columns of pixels, the thing is pretty easy because with the function pixel() I can make an array of values for each column. Instead I have to do a particular thing: assuming to have a round clock with an image in its own background, while the seconds hand moves, it takes the pixels in the image below and make up the array...
I have written this little sketch:
Thanks for your attention,
Roberto
First of all I have to say that I am italian and I am sorry for my poor english so I hope you will understand my question.
I should convert the pixels of a grayscale image (I use only white and black, not intermediate colours) to binary numbers, 0 if the pixel is white and 1 if it is black and I should put these values in some array. Suppose that the image is divided into rows and columns of pixels, the thing is pretty easy because with the function pixel() I can make an array of values for each column. Instead I have to do a particular thing: assuming to have a round clock with an image in its own background, while the seconds hand moves, it takes the pixels in the image below and make up the array...
I have written this little sketch:
- PImage img;
float degree = 0; // holds the angle for rotation
int counter = 0; // holds the steps for rotations
void setup()
{
size(220, 220);
img = loadImage("penguin.gif"); // loading the image
imageMode(CENTER);
smooth();
}
void draw()
{
background(255);
translate(width / 2, height / 2);
image(img,0,0);
noFill();
ellipse(0, 0, 200, 200);// transparent circle
if(counter < 100)// I make 100 steps of 3.6 degree
{
degree += radians(3.6);
rotate(degree);
counter++;
}
rect(0,0,1,88); // clock hand that rotates every step
// and now???
Thanks for your attention,
Roberto
1