Wednesday, July 2, 2008

Photomosaic 2

Yes!! I've got it. Thanks for the advice Mike. The problem was that one of my images was not the small version (25 by 25) it was the larger one (400 by 400). As you can imagine, this caused problems. I knew that the problem was in this line (i=501) but I couldn't find an error in the coding. I then checked the size of c7, this light green image and found out the size. This was easy to fix once I knew this!!



Here is the final mosaic.























The coding is the same as before but I changed the image name for c7:
















I have to say that this was a great learning experience. It is also addictive. I am tempted to keep improving the mosaic by finding a few different smaller images that are a better colour match. I will not do this though as I have a lesson to type up for Mike!

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.