Question
Problem : In this problem you have to write a MATLAB code that takes the provided image plain.jpg as input. You have to implement Bug
Problem :
In this problem you have to write a MATLAB code that takes the provided image "plain.jpg" as input. You have to implement Bug Eye Algorithm on the input image. Your output should be similar to the sample output image that is given below.
Steps:
1- Define the x, y pixel coordinates xout- yout of the output image using meshgrid function.
2- Compute the x, y pixel coordinates xin -yin of the input image for each xout - yout using transformation function T.
3- Compute the intensities of input image at location xin - yin, using interp2, which returns output. 4- Return output image.
HINT: You can hardcode the locations of the eyes and the parameters to the inverse mapping function. Alternatively, you should automate these steps with an algorithm to detect the solution and possibly the size of the eyes in the input image. The output image should get an effect like the following.
Short note on Algorithm Description:
For this project you have to learn about a spatial transformation technique known as inverse mapping and related MATLAB functions meshgrid and interp2.
Meshgrid Meshgrid is a commonly used function that defines the x-y coordinates of a rectangular grid. For instance, recall that the equation that defines a circle is given by (x) −xc 2+(y) −yc 2 = R2 where x and y define the circumference of the circle, xc-yc is the center of the circle and R is the radius of the circle. Knowing this, we can easily draw a filled circle using meshgrid like so:
Height = 100; R = height / 4;
[x, y] = meshgrid (1: height, 1: height);
r_squared = (x - height/2).^2 + (y - height/2).^2;
im_circle = r_squared < R^2;
imshow (im_circle);
Inverse Mapping: To spatially transform an image, we have to somehow express the relationship between the pixel locations of the input and output images. One approach is to answer the question, "For every pixel location in the input image, what is its corresponding location in the output image?" This approach is known as forward mapping. Forward mapping works well for simple transformations like translation, but often leaves "holes" in the output image under more complex transformations. Another approach is to answer the question, "For every pixel location in the output image, what is its corresponding location in the input image?" This is known as inverse mapping, which you can use to achieve the bug eye effect. Inverse mapping requires a function that maps a pixel location in the output image to a (not necessarily integer-valued) location in the input image. We will use the function.
T(rout) = s*rout Where: rout is the distance between the output pixel location and the center of the eye. T (rout) a.k.a rin is the distance between the input's pixel location and the center of the eye. S is some value between 0 and 1 that scales rout, r is short for 'radius' Intuitively, we want to enlarge the eye; Therefore, we want to map rout to some value smaller than rout. This explains why is smaller than or equal to 1. Furthermore, we want this bulging's effect to be limited to the eye area. This requirement suggests that s should be a function of rout, and more specifically, s should be at least close to 1 for large values of rout. With these constraints in mind, we define s as
S(r) / [1 xp(b( c r ))]
Where b, c, d are hand -tuned constants, and exp (x) is just a more readable equivalent of ex. This particular choice of s is somewhat arbitrary but suffice to say, it meets the needs of our problem. Other choices of s would be similarly effective.
Input image HITE Output image TE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started