Skip to content

NorahCSJZ/Computational_photography-project2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 

Repository files navigation

Computational_photography-project2

The goal of this project is to try to make a hybrid image, and to be more, to make a morphing gif

  1. Project details: First I collect some typical pictures, just like those:

bicycle

marilyn

Then, I need to write the filter,like the detail said, I tried to implement the Gaussian filter, and the equation would be:

image

so, according to this equation, I used numpy package to implement my 2D Gaussian filter, and then convolute the whole image using the filter, but then I found that, using this filter to convolute would lose some information around the edge, just like that:

image

you can see some of the ears and months of the dog get clipped, so I need to use some '0' to fill the edge so that the shape of the image could be divisible by the shape of the filter size, just like that:

low_frequencies_dog

and that's how I get the low frequency images. Then I use the impulse filter minus the Gaussian filter (which can be computed by subtracting the Gaussian-filtered image from the original) as you said in the project detail.Just like that:

high_frequencies_marilyn

high_frequencies_plane

and then, just hybrid it!But the prior problem is how to match up the size between those images,I have tried to use the Google API to locate the object and resize those images according to the proportion of the bounding size and the image size, but it's not worth that without a large scale of data in it, and for this project, I used some methods of data augmentation to make a bigger scale of data.Then I thought, what about rescale all the data so that the object in the pictures is all in the middle.So, at the end,I got this hybrid images:

hybrid_image_submarine_fish

using these two images:

fish

submarine

another examples would be:

  1. original images:

cat

dog

and the hybrid result would be:

hybrid_image_dog_cat

  1. original images:

marilyn

einstein

and the hybrid result would be:

hybrid_image_einstein_marilyn

  1. original images:

bicycle

motorcycle

and the hybrid result would be:

hybrid_image_bicycle_motorcycle

  1. original images:

image

sum-of-marilyns1

and the result:

backwards

For those images, I used the function you gave to compute and display the 2D Fourier transform, and the result would be :

image

image

image

image

More images:

Original:

Robert-Pattinson-as-Bruce-Wayne-in-The-Batman

joker-joaquin-hi-res

Hybrid:

hybrid_image_Bruce_Wayne_Joker1

hybrid_image_Joker_Batman1

Original:

Kb

michael-jordan-jersey

Hybrid Image:

hybrid_image_Kobe_Jordan1

Original:

90

saka_58

Hybrid:

hybrid_image_Smith_rowe_saka1

Original:

xiaohu

theshy

Hybrid:

hybrid_image_xiaohu_theshy1

2.Bells & Whistles:

  1. Generate a morphing gif:

The reason I thought of the following method is that for face morphing, all we need to do is to select some specific points in the first image and then find the corresponding one in the second image.When we find those points pair, the next thing we do is to make routes from one to the other so that we can generate the gif, so the model I used in it couldn't be more appropriate!

Luckily I have done one before, here is some details:

Using dlib and opencv to detect the face. Advices on working with facial landmarks with dlib and opencv https://www.pyimagesearch.com/2017/04/03/facial-landmarks-dlib-opencv-python/

the dlib model we used to detect face landmarks is put in the model folder

The facial landmark detector will give us the estimated location of 68 (x, y) pair coordinates that represent salient regions of the face, including eye, eyebrows, nose, mouth, and jawline.

Using inverse warping to do the morphing.Using Delaunay triangulation to organize each pair of feature points to a triangle.

the dlib model we used to detect face landmarks is put in the extra_lab/model folder and the model will automatically locate the points of each triangle corresponding.Then generate the gif!

In that way, I can see how the face morphing in a gif file!

the original two images are:

kanna

lmy7

and the output mp4 would be (here gives the link): https://www.bilibili.com/video/BV1NU4y1M7n4/

The problem of this project is that the quality of the morphing is determined by the first image in the model, because it is the standard of the whole morphing procedure.

  1. using color to enhance the effect

First I transformed the color space from RGB to HSV, but it doesn't work well

hybrid_image_dog_cat1

Then I transformed the color space from RGB to LUV, the result is kind of fairy:

hybrid_image_dog_cat1

Then I transformed the color space from RGB to BGR, it seems like we have better color:

hybrid_image_dog_cat1

Using gray image for both high frequency image and low frequency image and merge:

But first time it turns out to be green:

image

image

and I found out I missed one parameter when trying to show the grayscale image of .bmp file (when using pyplot to show the image), it is cmap=plt.get_cmap('gray')

but when I tried to use just gray image to get the low frequency image and merge with original high frequency image, I get this image which is obvious wrong.

image

Then I found it is when I get the range of my value in my low frequencies image wrongly so the hybrid is almost the same with the high frequencies image

after fixing this, I get:

image

And do the opposite, use just gray image to get the high frequency image and merge with original low frequency image, then I get this:

image

Both are the gray images:

image

Another example:

low frequencies image is gray when high frequencies image is a RGB image:

image

high frequencies image is gray when low frequencies image is a RGB image:

image

Both would be gray image:

image

I found that the color of the submarine image is quite dark, and the same with the fish image, so when I merge them together, you can just find some edges of the submarine, that's what I should be avoid of. But on the contrary, the hybrid image with bicycle and motor would be quite great, since they have some dark and bright colors, so that when hybriding, both could be seen much more clearly

Group Member:Jingzhou Shen

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages