Thursday 8 November 2018

Camera Input

Another part of my project that I have started to work on is the leaf scanner. In that, the installation will scan in leaves and extract some features from the image to be used as input parameters into the tree generator.

Back at the start of the semester I went out and gathered some 'literal' training data in the form of physical leaves. I then laminated these up thinking it would help preserve them...


Laminated leaves!


Unfortunately, I did not dry them out before laminating them, so they have now started to decompose. I may have to resort to using prints instead.


4 weeks later!

To scan the image in I simply made use of an openFrameworks tutorial that connects to and uses a webcam. From this, I can get access to the raw image data. The first thing I wanted to do was to analyse the image and find the most common colours.

To achieve this the image was first captured as a still. The image was then clustered into squares of 4x4 pixels and the average RGB values calculated. This initial clustering reduced the image by a 1/16 from 921, 600 data points (for a resolution of 640 x 480) into 57,600 points, which is far more manageable! From this, each of these values could then be stored in a matrix. Finally, this data was then piped into a K-means clustering algorithm. The centres of each centroid gave them most commonly used average colour values. Later in the development stage, this data will be propagated into the virtual trees to give them their colour.


Application showing input image left, compressed (1/16) image right. The blobs at the bottom are the average colour values from the K-means process.


White box with the camera placed at the top for capturing image data. Highlighters provide some colourfull test data! 










No comments:

Post a Comment