Tuesday, July 1, 2008

Photomosaic

As everyone can attest, it is difficult to find an image that, when shrunk, enlarged and reduced to 27 colours, is still identifiable. After much experimenting, I chose the following image of a window.

Unfortunately, I saved over my original large image with the small version:



I will try to find the large version on the internet if I finish this with time to spare.

Here is my image enlarged with 27 colours. It's size is 600 by 400.




















I determined that my image only used 27 colours. I used GIMP to determine the RGB values for these 10 colours. I found images that were close to these colours and I made them square and reduced their size to 25 by 25.




Well, it is coming along. I find the coding a bit frustrating. Thanks to those who found out that a double equal sign is needed in the coding!

Thanks also to Jenn who found out that a double & is also needed in the coding!

At this point in time, my program is only working for a square image. My image is rectangular. I will keep working. Here is the image so far.



















I think I might have figured out why!!

I went back and read the code and, no, I'm not sure.

Here is my code:
First I read in my 10 colours and my window image:
c1=imread("brownsqsm.png");
c2=imread("blacksqsm.png");
c3=imread("coppersqsm.png");
c4=imread("darkgrsqsm.png");
c5=imread("greysqsm.png");
c6=imread("lightpksqsm.png");
c7=imread("lightgrsq.png");
c8=imread("redsqsm.png");
c9=imread("whitesqsm.png");
c10=imread("yellowsqsm.png");
D=imread("windowc27even.png");

Then I tested the window image to determine which colour should be put in each location:











I will take a break and come back to try to get those last few rows filled in.

I had a coffee and came back to this refreshed. I remember Mike saying something about using a square image. I checked a few blogs and it seems that people used a square image for their large image. I will try to change my image. I searched for my original image, the problem is that I am not sure where I found it. I think it might by Flickr - do you know that Flickr has over 2 000 000 images of windows?? I did search for a while but to no avail. I will resize my large image to be square and see what happens.

Hmmmmm, I resized my image to by 400 by 400. I used the code and this is what resulted.


1 comment:

Mike Zabrocki said...

I don't think you should be using a square image for your large image. Why would you need this restriction?

The thing is that in your example image the place it is "working" isn't square. In fact it is (I think) 16 wide and 20 high. So the problem seems to be that the the i range isn't working very well. You should first try adjusting it by hand so that instead of saying the range is 1:25:(size(D,1)-24) try something like
1:25:26
and then
1:25:51
and then
1:25:201
until you can see what is going wrong.