Fun House Mirror Simulation

 

 

            Two kinds of fun house mirrors were simulated in my program. One is cylindrical mirror and the other is sinusoid mirror.

 

  1. The algorithm of sinusoid mirror simulation:

To simulate the reflection of sinusoid mirror, I assume the eyes’ position is at the 19/20 height of the whole picture, which is just the average ratio of the eye height to the whole person height.

The most important thing is to find exactly that which point is the reflection point. The reflection point is just the point at the mirror. The input ray come from image pixel and is reflected at that point, and then to into the eyes. To be coherent to the physical law, the input angle should equals to the out put angle. (See figure 1)

Figure 1

 

 

My method is searching all points in the sinusoid mirror from the bottom to the top in order to find exactly where the reflection point is. The criterion to looking for the reflection point for a pixel is : compute the input angle from the  given pixel to the present searching point; calculate the output angle from the searching point to the eye. And then store the error, which is the absolute value of input angle subtracted by the output angle, as one element of the error vector. After all the points have been searched, we can find the minimum of the elements in the error vector. The point corresponding to the minimum is just the reflection point we are looking for.

Because the mirror is sinusoid mirror, it is easy to find the slope of the tangential line of it by differentiating it. And then we compute the derivative function value of each point in the mirror. The inverse tangent of the value is just the angle between the law line and the x-axis.

We use the following code in matlab to compute the angle LawAngle:

 

LawAngle=atan(2*pi/SinMirrorPer*SinMirrorAm*cos(2*pi/SinMirrorPer*k))

  

   To compute the output angle from  the present searching point to the eye.

   EyeAngle=atan((EyeHeight-k)/ImageDistance);

 

   The input angle from image pixel to the present searching point can be computed as follows: where m is the height of the image pixel and the k means the height of present searching pixel.

   ImageAngle=atan((m-k)/ImageDistance);

   Then compute the error or deviation of present searching reflection point using follow codes:

   Error=abs(EyeAngle+ImageAngle-2*LawAngle);

  

   The program searching all the point of the sinusoid mirror in a set step length and compare their errors, find the point that has smallest error.

      Then the image that eyes see are just the symmetrical point of the pixel with respect to the line passing by the reflection point and tangential to the sinusoid mirror.

       The position of the image that eyes see can be computed as follows, where the k1 and k2 are the slope of the two light beam come into eyes.

    k1=2*pi/SinMirrorPer*SinMirrorAm*cos(2*pi/SinMirrorPer*ReflectPoint1(m+1));

   k2=2*pi/SinMirrorPer*SinMirrorAm*cos(2*pi/SinMirrorPer*ReflectPoint2(m+1));

   x1=ImageDistance;

   y1=EyeHeight;

   y2=EyeHeight-EyeSize;

   x2=ImageDistance;

   y=(k1*k2*(x2-x1)+k2*y1-k1*y2)/(k2-k1);

   ImagePoint(m+1)=y;   

 

    The intensity of the image point that eyes see is just same as the image input and the only thing different are their positions.

 

        The result of the simulation can be seen from figure 2. The left is the original image; the right is reflection image from the sinusoid mirror.

 

   

 

Figure 2

 

 

2.The cylindrical mirror simulation:

      The algorithm of the simulation of cylindrical mirror is very similar to the simulation of the sinusoid mirror. It can be found in the matlab code attached.  The result of the simulation can be seen from figure 3 and figure 4. The left is the original image; the right is reflection image from the cylindrical mirror.

 

   

 

Figure 3

 

   

 

Figure 4

3. Some funny geometric operation of image:

 

        Some experiments of geometric operation have been done. The result of sinusoid geometric operation can be seen in figure 5 and the result of circular geometric operation can be seen in figure 6.

 

 

Figure 5

 

  

 

 

   

 

Figure 6

 

All the matlab codes are attached.