Algorithms (Esenthel Project) Author Message
Tottel
Member

 Post: #1 Algorithms (Esenthel Project) Hello everyone, I needed to test an algorithm that I had to use at work, so I did what anyone would do: Make a new application in Esenthel and slap some things together there just to see if it works! Then, of course, I got a little bit carried away and added some more algorithms and put them together in a small, simple application. So, I'm putting that project up here in case this is of interest to someone. It's very basic, really, but it can always be nice to have some more tutorials! What it does (all algorithms are for image processing): - Bilinear interpolation (on colours) - Convert to Gray - Blur - Oil painting filter - Sin-wave blur. My god, it's so useless, why did I put time in that? Download Enjoy!
10-26-2015 09:00 AM
Esenthel

 Post: #2 RE: Algorithms (Esenthel Project) The oil filter is pretty cool :> Code: ```FREP(levels)             {                // IMPORTANT!! Memt have preassigned memory. This is faster than adding new elements, BUT this might crash the application if the image is too big!!!                // To be safe, a responsible person would totally replace [i] with .add(..); But the performance difference is noticeable..                intensityCount[i] = 0;                averageR[i] = 0;                averageG[i] = 0;                averageB[i] = 0;             }``` don't do un-safe programming (this also crashes in debug mode, because debug has range checks for memory containers) you can do this much faster by just doing: intensityCount.setNumZero(levels); ..
10-27-2015 12:37 AM
Tottel
Member

 Post: #3 RE: Algorithms (Esenthel Project) But but but, Esenthel! it's 0.15 seconds faster! Surely that's worth the risk. Anyway, I didn't know about setNumZero(..), I will check that, thanks! EDIT: Well.. setNumZero() is even faster. Nice. (This post was last modified: 10-27-2015 08:19 AM by Tottel.)
10-27-2015 07:59 AM
Zervox
Member

 Post: #4 RE: Algorithms (Esenthel Project) Using VecI makes it even faster in my case VecI and the setNumZero made it 100% faster, while setNumZero made it 50% faster Code: ```Memt intensityCount;             Memt averageRGB;             intensityCount.setNumZero(levels);             averageRGB.setNumZero(levels);                          for(int y2 = y-radius; y2 < y+radius; ++y2)             {                for(int x2 = x-radius; x2 < x+radius; ++x2)                {                   if(x2 >= 0 && x2 < image.w() && y2 >= 0 && y2 < image.h())                   {                      Color col = image.pixC(x2, y2);                      int curIntensity = (((col.r + col.g + col.b) / 3) * levels) / 256.0f;                      intensityCount[curIntensity]++;                      averageRGB[curIntensity] += col.asVecB4().v3();                   }                }             }                          int curMax = 1;             int maxIndex = 0;                      // Find the biggest intensity for each texel container             FREP(levels)             {                if(intensityCount[i] > curMax)                {                   curMax = intensityCount[i];                   maxIndex = i;                }             }             VecI temp=averageRGB[maxIndex] / curMax;                          Color col = Color(temp.x, temp.y, temp.z, 255);             texelColors[x][y] = col;``` (This post was last modified: 10-27-2015 10:45 AM by Zervox.)
10-27-2015 08:42 AM
Tottel
Member

 Post: #5 RE: Algorithms (Esenthel Project) Zervox: Indeed it is, thanks!
10-27-2015 08:47 AM
 « Next Oldest | Next Newest »