Where can I get simple data clustering algorithm?

Hi all, need help.
I am looking for simple algorithm for clustering data. My initial data is a set of values of some function (positive / negative) on an evenly (but will eventually go with variable spacing) spaced grid


. I would like to build clusters based on the sign of my function and local maximum/minimum. I do not want to cluster adjacent points if they gave opposite signs to my function, because on the next step of my algorithm I will be slowly eliminating points from a given cluster that yield abs(f)<abs(fmax)*const where abs(f) is an absolute value of my function at given point and abs(fmax) is an absolute value of local max/min, and const is some constant between 0 and 1. As a result I will have something like that

. Note my functions values depend on the available domain, so I have to recalculate after clean process. I would like to repeat the process till all less important points are eliminated giving to something like that

. I am hoping that I can build local clusters were my function eventually becomes semi constant.
I do not need any kind of fancy algorithms, something simple enough that I can use..
thanks a lot

I am not sure about the data you have, but have you looked here?
Clustering Components