Sunday, October 1, 2017

Single pixel "camera" - Application of Linear Algebra

Hello guys, have you thought of creating your own camera. To me, I have thought of this since I fell in love with photography and found out how expensive a camera can be. With that being said, I am going to introduce an easy and inexpensive way to emulate the mechanism of a camera through linear algebra.

All you need is a projector for masking, a circuit for collecting data, and of course an object you want to convert to an image.

Here is the circuit we will be using:

Important component: photoresistor(light sensor) and a launchpad to record, collect and transmit data to the computer.
Note: Photoresistor is a component which decreases its resistance as the surrounding light intensity increase, vice versa.

--------------------------------------------------------------------------------------------------------------------------

Mask Matrix:
In linear algebra, a matrix is just a container which contains all of the coefficients of a system of equations. For more information, please look for some other reference.

What is it:
A mask matrix is simply a matrix which contains all of the masks will be used during the data collection.

What does it look like:
The picture above is an example of a mask, and this will become part of the mask matrix eventually. Please note that a mask can be written as a matrix form (shown above) or vector form. As indicated above, 1 represents the untouched areas and 0 represents the blackened areas.

How does it work:
A mask is simply a signal to the projector telling it to cover up (make it black) a major part of the screen but leaves out one little part untouched (an example is above).
During the projection of the mask on the object, the launchpad will collect the data from the photoresistor in the form of analog signal.
The data collected from the photoresistor will tell us whether the illuminated area has something written on it or not. This can be explained using optical physics. An intuitive explanation is that black absorbs light and white does not, so the residue light after hitting on the object will be different depending on the color of the object. Then this residue light will be collected by the photoresistor resembling the object in the illuminated area.

--------------------------------------------------------------------------------------------------------------------------

What do we have up to now ??????
A mask matrix to shine the light on the object and a circuit to collect the light intensity.
Yeah, input and output. We got this.
Don't you see it? All we need to figure out the object is input and output.
The input is the mask matrix and the output is the light intensity measurements, we just need one more thing to connect them, which is the physical object.
But how does it really work?????
An intuitive explanation is to describe this as a system of equations.
In linear algebra, a system of equations looks like:
These are three equivalent representations of a system of equations.
In these representations, one thing in common is that we want to find the unknown variable (x,y,z) or unknown vector (the vector x) which multiplies by the corresponding coefficients will result in a certain number (d1,d2,d3) or vector (the vector b).
A particular thing we can observe from the system of equations is that this resembles our system, so we can definitely use it to find out our physical object.
In our case, the mask matrix is A, the physical object is the x vector, and the measurements are represented by the b vector.
Using what we learn from linear algebra, the vector x (physical object) can eventually be found.

To further explain how A actually look like:
In the picture above, H is the mask matrix A. Each row of H represents one mask. For example, the green-highlighted row represent the mask that will cover all pixels except the pixel in first row and second column. We can also notice that every time we use a row from the matrix H, we are actually converting the row into a matrix form, and this matrix has the size of the pixels we want to measure. 

No comments:

Post a Comment