HW048
Math 2984 - Fall 2017
Intro to Mathematical Problem Solving


TASK: Read a PNG file containing a grayscale image of a scene from the movie "Casablanca"; copy Ingrid Bergman's head and use it to replace the heads of Humphrey Bogart and Dooley Wilson; save the image as "bergman3.jpg".


COMMENT: A forger can try to manipulate photographic evidence by cutting and pasting bits of a picture. We will try a very simple version of such an exercise by locating Ingrid Bergman's head, copying it into a submatrix, and then using that to replace the heads of Humphrey Bogart and Dooley Wilson.

The tricky part of this exercise is deciding the coordinates of the heads. I will suggest that you look for Ingrid Bergman's head as a 100x100 block of pixels. Once you know M and N, the size of the image, you can make a rough guess for where to look, and you can check by using the imshow() command:

        imshow ( I(101:200,301:400) )
      
will display a typical chunk of the image, but you'll have to experiment to get Ingrid Bergman's head into the box. Note the coordinates that you found.

Now you can use imshow() to search for a 100x100 box around the heads of each of the two male actors. I don't know of any better way than to look at the picture and guess, and then try imshow.

After your investigations, you should have something like this information:

      Ingrid Bergman head: (a:b,c:d)
      Humphrey Bogart head: (e:f,g:h)
      Dooley Wilson head: (i:j,l:m)
      

Now you can try to replace heads:

      ingrid = I(a:b,c:d);
      I(e:f,g:h) = ingrid;
      I(i:j,l:m) = ingrid;
      
And if you are ambitious, you can try to get Ingrid's head to turn the other direction.


INSTRUCTIONS: Copy the file 'casablanca.png' from the Canvas homework site.

        I = (read the file into MATLAB)
        view the image I
        do your experiments to get the coordinates.
        ingrid = I(a:b,c:d);
        I2 = I;  <- Work on a copy of I.
        I2(e:f,g:h) = ingrid;
        I2(i:j,l:m) = ingrid;
        view the image I2
        save I2 to 'bergman3.jpg'
      


CHECK: You might get something like this:


SUBMIT: Your script file should be named "hw048.m", and begin with:

        % hw048.m
        % YOUR NAME
        % This script (describe what it does)
      
I do not need a copy of your plot.