Giter VIP home page Giter VIP logo

-computational_photography_final_project's Introduction

Computational_photography_final_project -- Photo Mosaics

1.Introduction

  1. image dataset

I created a dataset where all the images are of Kobe Bryant.So I wrote a scrapy program to get all the images they had of Kobe Bryant.The website is https://www.gettyimages.com. And download all the images which are relevant to Kobe Bryant. Just like that

image

And here we are, the Kobe-Bryant dataset are all set!The link of this dataset: https://drive.google.com/file/d/188WvOJIYxa49OwJDMKoqDt34bmJ39m4P/view?usp=sharing

original image is:

Kb

  1. Photo Mosaics

a) Method I (k-d tree): First I tried to use k-d tree to query the fittest image from our dataset to stick to the image block,so I check how to use k-d tree, here is the reference:

https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.KDTree.html

First, I collect average color for the output image and the images in the database, then use k-d tree to query it, but then I found that first, when I just query them, this happened

image

Then I found that in the calculation of dominant color, there exists one expansion only contains white elements, so just cut this dimension. After that, I found that those images I got from my scrapy codes are various in format, so that when I tried to query those images, I found some dimension errors, so in the begining of my codes, I transformed those images into 'RGB' format, that's the normolization part. Next thing I do is to adjust the image, about the size and other things. For example, some pre-treatment are needed, like erase the noise etc..

b) Method II(Using distance): First I need to adjust the image, since I have done lots of work in method I, I may not need to adjust a lot in color, but in size. This time, I would not resize all the photo to a certain scale, instead, by using aspect ratio for each image in my dataset. I just chose the image which has similar ratio to our grid size, so that it could fit better! After I did the method I, I have found that the key is to find the closest color to a specific grid zone in the output image, so what I need to do is to first, get the size of the output image and the grid size, second, for each grid, calculate the average color for this grid. After i get those information, all I need to do is to find the closest one from my dataset, just traverse the dataset once to find that. When I finished all the process, just need to put those selected images into those grids one by one, then it could be done ! here is the main function:

image

Then I have found that the output image I found has a large black area(not pure black, but has some color in it), so that when I handle those areas, it has a large possibility that it will use the same image. So first, for those black images, I created a few filters to make them slight lighter or darker, and then apply them randomly. Next, in case that the situation still happens, I have created a list where if some images use more than certain specific times, the function will query the next closest one.

3)Output image

Method I:

output

Method II:

output1

After finishing those, I found two problems, first, the background image has so many consistent color, like a big area of black or yellow, second, when I zoom in, I cannot see the images so clearly in each grid, and the last is that it may use one image so many times.

So in order to solve these, first I find a new image which has rich color in it:

t1

and enrich my dataset by crawling more images.

Next, I create a function which use some packages in PIL.Image, to create a high resolution image, here is the function

image

after that, a new problem occurs, that is the limitation of max pixels, so I just change this limitation by this:

image

and next when I set the grid to be (40, 40), it turns out to be like this:

output_three

I cannot see the background image so clearly, so I just changed the size of the grid

output_two

but I find out that I used one image so many times, so I just changed my query function of searching the kd-tree by adding k into it, and create a list where it doesn't allow to use the same picture within a certain distance.

Finally, in order to see the image in each grid clearly, I used the resize function in our dataset.

After all those preparations are set, just run the program, it turns out to be like that

output_three

Note: I just find that the gettyimage might have some way to prevent big-scale crawling so that the resolution of images scale down.And it has a threhold when I want to increase the resolution.

Other work:

original:

1720866

Mosaics:

image_name:

I searched for lots of ways and implentment on my own

-computational_photography_final_project's People

Contributors

norahcsjz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.