Local maxima?

   1041   2   1
User Avatar
Member
255 posts
Joined: Sept. 2012
Offline
For several cases, I have this need to find the local maxima for a parameter or for a heightfield volume.
For now, the only thing I could think about is to split into cluster
Is there a better algorithm for this?

Have you faced this question before?
If so I'm interested to hear your words
Vincent Thomas   (VFX and Art since 1998)
Senior Env and Lighting  artist & Houdini generalist & Creative Concepts
http://fr.linkedin.com/in/vincentthomas [fr.linkedin.com]
User Avatar
Member
8531 posts
Joined: July 2007
Offline
- for parameters do you mean local maxima of animation curve?
you can use CHOPs for that for example Channel Wrangle:
float prev = chinput(C, I - 1);
float next = chinput(C, I + 1);

V = (prev <= V) && (next <= V);



- for heightfields you can do it in a similar way in Volume Wrangle, imply compare height of a current voxel to its neighbors and if all of them are smaller place a point or something (Volume Wrangle on isolated height volume):
float h = @height;
vector i = set(@ix, @iy, @iz);
vector is[] = array(i + {1,0,0}, i - {1,0,0}, i + {0,1,0}, i - {0,1,0}); // orthogonal neighbors
vector is2[] = array(i + {1,1,0}, i + {1,-1,0}, i + {-1,1,0}, i + {-1,-1,0}); // diagonal neighbors
append(is, is2);

int ismax = 1;
foreach(vector ni; is) {
    float nh = volumeindex(0, "height", ni);
    if (nh > h){
        ismax = 0;
        break;
    }
}

if (ismax) {
    int pt = addpoint(0, v@P);
    vector P = v@P + set(0, h, 0);
    setpointattrib(0, "P", pt, P);
}

removeprim(0, @primnum, 1);
Edited by tamte - May 7, 2022 11:47:29

Attachments:
ts_local_maxima_channel_and_heightfield.hipnc (184.0 KB)
ts_local_maxima_channel.png (9.4 KB)
ts_local_maxima_heightfield.png (99.8 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
255 posts
Joined: Sept. 2012
Offline
Wow, i didn't know much people who you will have be able to provide such a great and smart solution here, you are a true houdini rock star Tomas!

Didn't noticed your example until now but it was easy to get it , Thanks you so much for sharing your knowledge! @tamte
Edited by vinyvince - May 7, 2022 17:49:20

Attachments:
Houdini_Volume_LocalMaxima2.PNG (1.8 MB)

Vincent Thomas   (VFX and Art since 1998)
Senior Env and Lighting  artist & Houdini generalist & Creative Concepts
http://fr.linkedin.com/in/vincentthomas [fr.linkedin.com]
  • Quick Links