Computer Science Canada

PicMerge Version 1.0

Author:  Delos [ Sun Aug 29, 2004 5:57 pm ]
Post subject:  PicMerge Version 1.0

Greetings fellow CompSci.ca-ers.

A while back I released this. Suffice it to say, it was rather sublime at best. Over the last few days, I've resurrected my efforts to create a functioning alogorithm to do what that code could not.

And here it is.

The readme file will explain everything.

Note that the interface is crashable...it is not nearly as important as the rendering itself.

Post comments/bugs/suggestions et cetera.

- Delos

PM me if you need the file in a format other than .zip.

Author:  the_short1 [ Sun Aug 29, 2004 6:39 pm ]
Post subject: 

ummm... u do know u can use



Pic.Draw (x,y,name,MERGE) or soemthing like that...

?

Author:  Delos [ Sun Aug 29, 2004 10:48 pm ]
Post subject: 

My dear, innocent, confused short1.

Dl the proggie. Run it. *Then* tell me to use picMerge.

Author:  the_short1 [ Sun Aug 29, 2004 10:57 pm ]
Post subject: 

ok..i will tomorow.. yea.. foolish me..

Author:  Paul [ Mon Aug 30, 2004 8:48 am ]
Post subject: 

Very Very nice man. This program can do what I couldn't do in less than 1 minute (before I had photoshop) and could still do it faster than I can do in photoshop. Have all my bits Wink

Author:  JHDK [ Mon Aug 30, 2004 1:12 pm ]
Post subject: 

When the pictures are different sizes it gets messed a bit.
However it's a great program you coded here.

Author:  Delos [ Mon Aug 30, 2004 1:14 pm ]
Post subject: 

Yeah...differing pic sizes do pose a minor problem. I've begun work on an update, which will basically be the same thing, but will have more options and such...if indeed it comes into being...hehehe.

Author:  rizzix [ Thu Sep 02, 2004 2:19 pm ]
Post subject: 

hmm well wanna testdirve my alpha lib? its based on the latest imglib of mine.. its not the same as the one poseted in the forum... a little diff.. too lazy to update it here.. cuz well it has more than one file heh.

Author:  rizzix [ Thu Sep 02, 2004 2:37 pm ]
Post subject: 

aha i tested my stuff out my self. Mr. Green... and here's the result.. but for those still confused what the program i supposed to do.. its all about transparency! lol

test2.bmp is transparently placed over
test3.bmp (the background)
at an alpha index of 0.5
and you get
result.bmp

Author:  the_short1 [ Thu Sep 02, 2004 6:28 pm ]
Post subject: 

just like in paintbrush...but with more then juse the white color... hmm... od... i have absolutely no clue how u did that.... nifty... i didnlt clue in at first cuz im stupid... duh..

Author:  rizzix [ Thu Sep 02, 2004 6:57 pm ]
Post subject: 

want to see something even cooler? try using an alpha mask instead of another picture. and see the really cool effects u can attain!

i'm attaching a monochrome alpha mask (basically what this means is that it can only state whether an area is to be displayed or not) u can still use alpha setting but it will result in a the picture merging with the white background where there is no "set bit" and will result in a faded image.. u can get around this by simply fixing the alpha index to 0.

Author:  Delos [ Thu Sep 02, 2004 10:08 pm ]
Post subject: 

Neato!

So does this mean that I inadvertantly stumbled upon a form of 'alpha-masking' meself? Now that would be an acheivement...

Author:  the_short1 [ Fri Sep 03, 2004 11:42 am ]
Post subject: 

delos.. omfg... u are a GOD..

thats something ... wow..



true it made it look like shit for the thing i made cuz it had over the 255 colors... Sad


dam..


im curious to how it works....

is it something like:


read (1,1) of first picture... output to result... read (2,1) of seond picture.. output to result... read (3,1) of frsit picture.. output to result..

pixel by pixel.. then to the next row..
???

Author:  the_short1 [ Fri Sep 03, 2004 11:48 am ]
Post subject: 

MAN! thats just a great program! really good for making GRADIENTS!!!!!



and i have a suggestion.... isntead of asking first pic and second pic... say foreground and background... yea i read the readme.... but that way there.. ppl dont have to to generate the result they like...

Author:  rizzix [ Fri Sep 03, 2004 12:26 pm ]
Post subject: 

hmm no one wants to testdeive my program? (and i being a programmer.. feel very dissapointed) Crying or Very sad

Author:  Paul [ Fri Sep 03, 2004 3:12 pm ]
Post subject: 

I'd test it, but I'm content staring at the jiraiya picture all day.

Author:  Delos [ Fri Sep 03, 2004 7:11 pm ]
Post subject: 

Frog Hermit!!! Boo-yeah.

And if you really want your proggie to have interest taken in it, make a thread! Lol.

And short1, thank you for the regal comment, much appreciated. As for how it works...that may go with me to the grave...hehehehe...it's not that complicated once if you take a look at the last number of submissions of mine...you'll see a pattern.

Author:  apomb [ Mon Sep 13, 2004 11:19 pm ]
Post subject: 

hey delos, i was messing around with your last code submission (sort-of merger, but a lot more grainy) in this thread and i came up with my avatar! i think it worked O.K, but i cannot see what the real picture would have looked like cuz i deleted the "compwiz" turtle pic :*(

Author:  Delos [ Tue Sep 14, 2004 3:52 pm ]
Post subject: 

Hmm...at the moment I cannot actually see your avatar! Perhaps your hotlinking is, umm...full of "features".

I tried a direct link to the Google site its hosted on and got a '502 Server Error'

Author:  Paul [ Tue Sep 14, 2004 4:36 pm ]
Post subject: 

his avatar is apparently a gmail attachment... for a second there, I thought it to be an invite... then it'd be clever indeed.

Author:  apomb [ Wed Sep 15, 2004 8:58 am ]
Post subject: 

well, i can see it no matter where i am Confused , mabey ill change the placement of it...

Author:  Delos [ Wed Sep 15, 2004 11:35 am ]
Post subject: 

Wherever you are? Wow...maybe cookies for you? I just see the x-box thingy...

Author:  apomb [ Wed Sep 15, 2004 8:18 pm ]
Post subject: 

ya, i cant see it now, im on a different computer ... whatever, CHANGED

Author:  jamonathin [ Tue Jul 05, 2005 9:30 pm ]
Post subject: 

I know this a really old topic, but i know that Delos is still around, and . . you shouldn't refer to it expecting no one to post on it . . Laughing .

Anyways, I was looking at these programs, and im curious to know how you did them. I made one of my own, and below is the result of what i got, however it takes like, seriously 15 minutes to do. Quite rediculous.

I was wondering if anyone of you guys could help me find a way to speed up this pos. Confused

Author:  Delos [ Wed Jul 06, 2005 9:42 am ]
Post subject: 

Well, for a start you can remove things like "drawdot (w, h, black)" since they will slow things down.
I ran it on some pics, about 300x400 and it took less than a minute. I'm guessing your computer is slow?
Anyhow, your method is pretty tripped out. And not in the good sense either. You have 3 loops (of 6 possible) that a single pixel must go through before it is released. Themselves, wrapped in if statements.
Yes, that is very slow.

And what do these loops accomplish? Well, it looks as though it is attempting to find some 'common ground' between the two pixels being analyzed. So, why go through the slow, laborious, and ultimately inaccurate process of comparisons, subtractions, and iterations - when you could simply take an average.
All of a sudden, ~5 iterations has been cut down to 1! Try it, it should work faster.

Author:  Cervantes [ Wed Jul 06, 2005 10:15 am ]
Post subject: 

Jamonathin: Why do you have to loop through and incriment the r, g, and b values until they are close together? Why don't you just average them? That's how I figured these things were done. Also, don't drawdots all over the screen. If you want that effect, just draw a fillbox.

Here's what I've done. It's a heck of a lot faster, largely because I don't have those incrimenting loops. Also, I didn't bother storing the colournumber of the second picture. I just used it immediately in my calculations.

If you want to merge two pictures of different sizes with this, make sure the smaller picture is pic1. There's probably a problem (ie. it will redraw the pixels and make them look shitty) if one picture is wide and the other is tall.

I think things would look better if Turing's colour palette were better. We're limited to having 256 colours, but does anyone know an algorithm to create a good palette within those 256 colours? It should not be like Turing's hard colours -> softer colours -> darker colours -> very dark colours.

If you uncomment the for loop (lines 10 to 12) you can get a nice looking greyscale merge.

Here's the code. I used pictures from my FP.
Turing:

var pic1 : int := Pic.FileNew ("theatre/Pictures/main.jpg")
var pic2 : int := Pic.FileNew ("theatre/Pictures/intro.jpg")
var maxWidth := max (Pic.Width (pic1), Pic.Width (pic2))
var maxHeight := max (Pic.Height (pic1), Pic.Height (pic2))
setscreen ("graphics:" + intstr (maxWidth) + ";" + intstr (maxHeight) + ",nobuttonbar,position:center;center")
var c1 : array 0 .. maxWidth, 0 .. maxHeight of int
var r, g, b : array 1 .. 2 of real

%Make the pallete shades of grey
%for i : 0 .. 255
%    RGB.SetColour (i, i / 255, i / 255, i / 255)
%end for

%Using whatdotcolour, get the colour number of each pixel in the first picture
Pic.Draw (pic1, 0, 0, picCopy)
for x : 0 .. maxWidth
    for y : 0 .. maxHeight
        if x <= Pic.Width (pic1) & y <= Pic.Height (pic1) then
            c1 (x, y) := whatdotcolour (x, y)
        else
            c1 (x, y) := -1
        end if
    end for
end for

%Draw the second picture, get the rgb values for each of it's pixels, average them, then draw the new picture.
Pic.Draw (pic2, 0, 0, picCopy)
for x : 0 .. maxWidth
    for y : 0 .. maxHeight
        if c1 (x, y) ~= -1 then
            RGB.GetColour (c1 (x, y), r (1), g (1), b (1))
            RGB.GetColour (whatdotcolour (x, y), r (2), g (2), b (2))
            RGB.SetColour (0, (r (1) + r (2)) / 2, (g (1) + g (2)) / 2, (b (1) + b (2)) / 2)
            drawdot (x, y, 0)
        end if
    end for
end for

Pic.Save (Pic.New (0, 0, maxx, maxy), "merge.jpg")


EDIT: Aah, the database died as I was posting this. A lot of this is a repeat of what Delos said. Ah well.

Author:  jamonathin [ Wed Jul 06, 2005 10:55 am ]
Post subject: 

Delos wrote:
Well, for a start you can remove things like "drawdot (w, h, black)" since they will slow things down.
I ran it on some pics, about 300x400 and it took less than a minute. I'm guessing your computer is slow?

Slow's an understatement, which is why i did draw the dots. By drawing the dots, yest he program did slow down, but not by too much, I just used the dots to tell me where I am so far on gettin every color. Thats also why i used that put statement; so i could see how far i was.
Delos wrote:

And what do these loops accomplish? Well, it looks as though it is attempting to find some 'common ground' between the two pixels being analyzed. So, why go through the slow, laborious, and ultimately inaccurate process of comparisons, subtractions, and iterations - when you could simply take an average.
All of a sudden, ~5 iterations has been cut down to 1! Try it, it should work faster.
Which would fall under the KISS category. I always seem to forget my grade 8 math Doh!

So yeah, thanks for your adice guys, and your coding cervantes. Makes too much sense Razz. Just one thing I'm curious about.

Delos: how do you get the colors of the dots without actually drawing the images? As it is in your program Confused

Edit: I juss got ur .zip file, thats a really good idea on how o do a grayscale. Pertsy cool. Smile

Author:  Delos [ Wed Jul 06, 2005 2:10 pm ]
Post subject: 

If you want to see some *impressive* colour manipulation, then look for my Lens Filter (version 3) proggie.
As for getting the colours off the pictures without opening them...that's my little...umm...secret I guess. It's really not that tough, but you have to be in the right frame of mind for it to work.

Link!.
Wow, I had no idea that I'd taken down the .zip. Ah well, I've added another one to it.


: