Skip to content

Fish Eye Transformation

pmsierra edited this page May 17, 2021 · 4 revisions

This Tool for the Image Processing Application allows the user to use a Fish-Eye Transformation on an image, and save it on its computer. The Tool also allows to transform multiple images in its own menu, but the user should load the set of images to transform prior to enter the tool.

FISH-EYE TRANSFORMATION

Fish-Eye transformation is a form of image warping, meaning the position of some points are mapped to other positions while maintaining the color value of it. This results in a distortion of the image, or on the contrary a fix to a previous distortion. In the case of Fish-Eye trasnfomation, the image is being warped to a spherical form, which causes a curious effect as if the image was being seen with a Fish´s eye, therefore its name.

To achieve this warping, the edges of the image have to become a curve instead of a corner. We first stablish the radius of the sphereical shape, and we move from the outside to the interior. To make things easier we divide the image in quadrants, so we have to compute the same operations in all 4 quadrants.

            [r0 c0 d0] = size(image);
            maximum = max(r0,c0);
            imo = imresize(image,[maximum maximum]);
            m = floor(maximum/2);
             
            image00 = imo(1:m,1:m,:);
            image01 = imo(1:m,m+1:end,:);
            image11 = imo(m+1:end,m+1:end,:);
            image10 = imo(m+1:end,1:m,:);

Now we have to take the first 2 lines that intersect with each other at a 90º angle and are perpendicular to the central axis. This may sound complicated, but it is easy once you get the first pair of these lines, which are none other than the corners of the image itself. We map those lines to the arc formed by the points where the lines intersect with the axis, as if the sharp corner would have been smushed. Once we have those points transformed, we already have the edges of the sphere. We then continue iterating for the next lines that fullfill our previous requirements. This iterations will form concentric arcs that come closer and closer to the center.

              %iteration for one of the quadrants
              for i = 1:m
              u = image00(m:-1:i,i,:);
              v = image00(i,i+1:m,:);
              s = [];
              s(:,:,1) = [u(:,:,1)' v(:,:,1)];
              s(:,:,2) = [u(:,:,2)' v(:,:,2)];
              s(:,:,3) = [u(:,:,3)' v(:,:,3)];
              cd = size(s,2);
              dss(i,i:i+cd-1,:) = s;
              R = m;
              for j = 1:0.2:cd
                a = 90*j/cd;
                q = m+1-floor((m-i)*cosd(a));
                p = m+1-floor((m-i)*sind(a));
                ds(p,q,:) = s(1,floor(j),:);
              end
            end

It is worth noticing that the further you go the the corners of the image, the more distorted the image will become. This is why the center of Fish-Eye images appear to be somewhat normal, but the edges appear highly distorted.

DEMO

To properly use this tool, the user first has to load an image on the Application Menu, and then select the Fish-Eye tool. The selected image will be displayed on the tool screen, as well as in the drop down menu. If more than one image is loaded, the latest image will be the one to be shown, but the user can access the list of loaded images from the drop down menu.

Once the image to be transformed is selected, the user may press the transform button to get the transformed image, which will be displayed in the tool screen after a short delay. The user may select another image from the drop down menu, and the image of the tool will be updated to the selected image. After the first transformation has been done, the export button will be enabled, so the user can push it to create a figure of the transformation, in case it is needed elsewhere.

FishEyeDemo

Clone this wiki locally