Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 PicMerge Version 1.0
Index -> Programming, Turing -> Turing Submissions
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Paul




PostPosted: Fri Sep 03, 2004 3:12 pm   Post subject: (No subject)

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




PostPosted: Fri Sep 03, 2004 7:11 pm   Post subject: (No 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.
apomb




PostPosted: Mon Sep 13, 2004 11:19 pm   Post subject: (No 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 :*(
Delos




PostPosted: Tue Sep 14, 2004 3:52 pm   Post subject: (No 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'
Paul




PostPosted: Tue Sep 14, 2004 4:36 pm   Post subject: (No 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.
apomb




PostPosted: Wed Sep 15, 2004 8:58 am   Post subject: (No subject)

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




PostPosted: Wed Sep 15, 2004 11:35 am   Post subject: (No subject)

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




PostPosted: Wed Sep 15, 2004 8:18 pm   Post subject: (No subject)

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




PostPosted: Tue Jul 05, 2005 9:30 pm   Post subject: (No 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



colormerge slow.t
 Description:
Use 2 samesized images under 100 pixels

Download
 Filename:  colormerge slow.t
 Filesize:  2.47 KB
 Downloaded:  126 Time(s)

Delos




PostPosted: Wed Jul 06, 2005 9:42 am   Post subject: (No 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.
Cervantes




PostPosted: Wed Jul 06, 2005 10:15 am   Post subject: (No 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.



merges.zip
 Description:
Contains images of the merges using Turing's standard palette and using the modified greyscale palette.

Download
 Filename:  merges.zip
 Filesize:  203.7 KB
 Downloaded:  103 Time(s)

jamonathin




PostPosted: Wed Jul 06, 2005 10:55 am   Post subject: (No 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
Delos




PostPosted: Wed Jul 06, 2005 2:10 pm   Post subject: (No 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 28 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: