Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Image-Filter Library

Author
Message
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 10th Sep 2007 21:44 Edited at: 13th Sep 2007 19:15
Hello again,

because I am a big fan of image-editing using memblocks.. I decided to write a function library about it. (Like always... function libraries for everything!! )

The point is, that I want to concentrate on my main-project now and so I don't really want to spend all of my time in coding image-filters.

So, here we go, I started a small collection of functions to edit images, and hope that I can help someone with it (Yes, I know, I'm so extremely social! ).
But I hope that you can help me expanding this functions. (If you don't know how to work with memblocks, I could quickly explain it (or you just look at the code below), it's really simple.) I would appreciate any kind of image-filter's you code, that can be a change of the alpha-value (already some functions for this kind of filter written), or Bloom, Smoothing/Blur, Relief, or even the generation of images (for instance heightmaps or textures).

Some months or years ago I made a small (still unfinished ) image-filtering-program with such filters, there was also an oil-painting-filter, nightvision, contrast, Light, Color-Extremes etc. So there should be enough room for creativity.

Just to let you know, I used the search-function, but didn't find any thread relating to this topic... just one three-year-old with 4 of such functions by Phaelax, but it doesn't really fit there.

If you are wondering about the aim I'm targeting... Umm... I think I just want to have power.




Let's go more into detail now.

As I mentioned above I already wrote some functions, which I am probably going to improve, and add new functions.
I will also add the functions of other users to the list, if they want to.

Now a list of the functions I made:

Quote: "
-Black-White
-Negative
-Light [changes all pixel-colors by a specific factor]
-Alpha from Light [Each alpha-value depends on the color-values of it's pixel]
-Global Alpha [All alpha-values are set to a specific value]

-Blur
-Bloom (more or less)
-Image Multiplying

-Generation of Debug-Backgrounds (Umm, yes...)
-Filled circle with 2 specific angles
-Sun
-Windows-Style-Button
-Antialiazed circle
"



And a list of some functions I planned to make... or to let somebody else make.

Quote: "
-Contrast [depending on the average (global or local) image-colors]
-Relief [Showing the color-gradient]
-Sharpen
-Smooth edges [Big contrast in small areas are smoothed]
"



Maybe some functions, which could be written, creating some more or less often needed images:

Quote: "
-Sky/Clouds
-Grass/Earth/Sand
-Heightmaps
-Evt. some standard-toolbar-icons [save, open, new, cut, copy, paste...]
"



I tried programming such "Bloom"-Filters in the past, but all of them were way to slow to be used in a program. (20 seconds for an average-sized image are to much imo..)
And that's one important aspect of the functions -> speed.
They should be as far as possible optimized, my functions here are probably not for 100 percent, but I tried to code it as good as possible.
The next important aspect would of course be the quality of the effect.


Enough theory... here are the functions I created, for the moment without example-code, if somebody is interested, I will make one demonstrating the actual features.




Sorry for the "de_img_"-Prefix I used for everything, but I like my function-libraries structured this way.


I am not quite sure if such a thread is really a good idea, but on the other hand, why not.
It would be great if some people posted their functions here, so everyone can use them in his projects, or somebody can program a tool containing all these effects for image-editing.

I will post some screenshots later..

Thanks in advance for anything.

Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 10th Sep 2007 23:53 Edited at: 11th Sep 2007 00:41
After some problems I also got a Blur-Filter working.

For a very efficient blur it needs ~3 seconds on images with 1280*1024 pixels on my computer, I think for DBP that's acceptable.







-Edit-

I wrote a new function, creating a small 3D-looking (haha ^^) box, which could contain Debug-Information or a chat-system, I sometimes used such techniques to make the debug-info look less like debug-information.
I know it's rubbish xD but however, I personally sometimes need such a function, so why not.

Here a really amazing screenshot demonstrating the extremaly awesome result:






So, I will go to bed now (11:40 PM here in germany ), have fun with the functions, or don't, or do whatever you want, or don't do it, or whatever... The best for me would be to shut up now.

culmor30
15
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 11th Sep 2007 02:11
Wow, that's some nice stuff. It'll be useful, thanks
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 11th Sep 2007 19:54
I made a bloom-filter today, which works, more or less, but still is very slow, because it should check a square of at least 10*10 pixels around each one for a good effect.. that area is 5 times bigger then the normal smooth-square, so it's also about 5 times slower.


Here an example:



@culmor30: Thanks, I hope so.

Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 13th Sep 2007 12:31 Edited at: 13th Sep 2007 16:20
I just made a new function, creating a filled circle of a given size between 2 angles, so it's possible to make an alternative healthbar for example. (I got the idea from another thread, from the code-snippets board. )

Image:




Function:




Edit: I made a small test, and realized, that a call of this function for a 90*90 pixel-big filled circle (which should be a good size for a game with small resolution) needs less than 20 ms, so it should be possible to use it in realtime.

Edit2: it just needs 20ms when the circle is created the first time. If you just change the existing one, it's done in less than 1 ms.

Edit3: A similar function creates a sun with transparent border.







Edit4:
A new function is made, which multiplies two images.




Function:





Edit5(lol):

Now there's also a size-image function, but atm. it's not smoothed ("antialiazed" ) but looks rather bad.




Edit5b: Forget the function above, there are some bugs I didn't notice at first.

Edit6: Because I was so bored I made a function which creates a windows-button of variable size with the normal colors.. the text has to be pasted manually though.





Function:



Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 13th Sep 2007 19:08
Bump.


I wrote a function, drawing an antialiazed circle onto an image.




Code:



Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 13th Sep 2007 22:15 Edited at: 14th Sep 2007 00:09
That is my 4th post in a row now, I don't want to happen this again!

So somebody has to write something now... so I made something special and included a perlin-noise-algorithm to create heightmaps of a certain size with different other parameters (Frequency, layers, Detail-Factor, Amplitude).
I created a 400*400-pixel big heightmap and smoothed it, the result looks like this (as you can see in the corner it needed 1150 ms for the complete generation!).





Edit: (yeah, edit-overload! )

Just to inform you, the created heightmaps are now seamless.



It's also possible to create sky-textures, different normal-maps (e.g. for water-shaders) and other funny stuff with the algorithm without much work, will post some screens later if possible.

Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 17th Sep 2007 17:12
Sorry for "double"post...

Here a sky-texture:




And the complete sourcecode, including perlin noise.



BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Sep 2007 18:13
All very nice. This is one of those things that you don't see a use for straight away. But one day you wake up and say "Today I need Mr Kohlenstoff's image algorithms!"

I like the height maps, they would be really useful for random terrains.

Ric
18
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 17th Sep 2007 19:30
Agreed - this is a very useful collection of functions. I have added this thread to my favourites for the day that I need them - I'm sure it will come. Keep up the good work!

Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 20th Sep 2007 14:44
Thanks for the comments, if anyone has suggestions for new functions it would be very nice if he could try coding them on his own, or if he doesn't want telling me what to do, I'll have much time the next weeks.

BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Sep 2007 16:22
If you want to include my memblock tutorials in your library, they might be a nice addition. These are image transitions, the source code is in the tutorial:

Linear transitions

Transitions based on a Mask

jason p sage
15
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 20th Sep 2007 23:33
Added to my Favorites too.

Where did you learn about the perlin-noise-algorithm - should I google myself or do you have a link you'd recommend?

Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 21st Sep 2007 00:58
Quote: "Where did you learn about the perlin-noise-algorithm"


The story is a bit weird... I read about the algorithm and didn't understand anything. Later I thought out my own algorithm, but found out some weeks ago that both algorithms were exactly the same.. The german and english wikipedia don't really contain any information about the algorithm, but I think I found some information in the Delphi-wiki. It's also the first google-Link, so you'd find it anyway.
http://wiki.delphigl.com/index.php/Perlin_Noise

They also wrote something about sine-interpolation, what is quite usefull and can easily be converted to dbp.

Good luck.

jason p sage
15
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 21st Sep 2007 01:12
Thank You, Good Job on the functions, and very good of you to post

flashing snall
16
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 3rd Oct 2007 02:19
woa, way cool, if you could post some example or showcase stuff, that woud be great.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 4th Oct 2007 11:55
Quote: " if you could post some example or showcase stuff, that woud be great."


I will see what I can do. Do you want to see anything special?

However, I also made a function creating a sky full of stars. You can use it to create backgrounds for e.g. space-shooters like space invaders. It's also easily possible to create different layers and let them scroll independently to get a 3D-Effect.

You can find the Starfield-Demo here:

http://mrkohlenstoff.mr.funpic.de/Sonstiges/Starfield.rar


And here's a screenshot:





Will post other examples later if possible.

flashing snall
16
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 4th Oct 2007 21:44
thank you so much.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Dr Schnitzengruber
15
Years of Service
User Offline
Joined: 19th Jul 2007
Location: C:/Projects/failed/ schnitzengruber
Posted: 5th Oct 2007 20:09 Edited at: 5th Oct 2007 20:13
Can you make one of the Julia set(maybe a 2-d slice of this 4-d object)

Julia set

The German wikipedia has a little more information on using exponets to change angles, this could make the julia set a 5-d object
Julia set

the answer to life the universe and everything = 42
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 6th Oct 2007 01:06 Edited at: 6th Oct 2007 02:32
I read some codes about the mandelbrot-algorithm on the forums and will try to add it to my functions.. I still don't really understand why the results look that cool, but at least I now know how to calculate them.

Edit: Mandelbrot works.

Thanks to spooky and Altreides for their codes, I wouldn't have got it work without them.

Here a snapshot:



And finally the function's code:



Edit 2:

Here an image with zooming, as far as floats allowed me to go:



Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 6th Oct 2007 23:40 Edited at: 7th Oct 2007 00:55
Today I worked on some Direct-Draw functions for draw-tools like in paint. It's possible to draw dots onto images and to spray, radial or squares. With this functions I made a small program, in which you can create greyscale-images with the given tools, load color-templates, smooth your image and "render" coloured images. It's very usefull for effects like explosions.





And with changed colour-settings:



Here the latest code.



Phaelax
DBPro Master
19
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Oct 2007 01:13 Edited at: 7th Oct 2007 01:14
Quote: "Just to inform you, the created heightmaps are now seamless."

As long as you create a perlin texture size as a power of 2 then it should always be seamless. I played with a perlin noise generator once, it's not easy to get it right, especially considering the lack of good documentation. So good job.

Excellant work. I think you should join the DBP challenges. We need someone to have fancier built-in graphics than Ric for once!


Login to post a reply

Server time is: 2022-09-25 11:55:01
Your offset time is: 2022-09-25 11:55:01