Well, what I get from your question is that what you want to do is segmentation. First you need to consider how many bumps you want to detect, because in every pixel exist a set of probabilities for every bump. I am going to try to explain it in an exaple.
Imagine that you are working with a MRI image like this one:
Suppose you want to classify the different tissues that appear in it, due to the tissues in MRI look to have a gray tone deppending on what kind of tissue are (gray matter, white matter, skull, skin, not-a-tissue, etc).
I am going to work with assuming that in the image exists 6 types of tissues (including the not-a-tissue region or black zone). [In terms of apples I am going to have a combination of apples in each pixel of 6 different colors and I am goig to find what color is predominant in each pixel]
To classify and labeling each tissue I am going to resort to GMMF ( Gaussian Marcov Fields). And this will be my results:
In the set of binarized imges, each pixel shows the principal bump in it. But in the upper set, the probability of each bump in the pixel is shown.
Finally this is the algorithm to perform the GMMF:
% A Gaussian Kernel that will be needed
kmu= [0 0]'
ko= [2 2]'
vi= [1/ko(1) 0; 0 1/ko(2)].^2
% 1: Assum some initial conditions (umbrals, means, variances)
mu=[10 50 90 130 170 210] //My initial hypotesis of which color is each
o= [ 5 5 5 5 5 5] //My initial hypotesis of how much varies each
E=[mu o] // My vector of results to stablish a stop criterion for the
e=sqrt(E*E') // My tolerance criterion (The squared root of the sum of each
//squared element of the vector sqrt(E1^2 + E2^2 + ... + En^2)
while e>0.5 % e<3
Ei=E //To compare how much imporve my results
t=0:255 // A vector for the possible gray tones in the image
T=zeros(1,256) // A vector of zeros
for h=1:length(mu) //length(mu) =6 in this case
% 2: Computing some likely hoods
% 3: Normalizing
% 4: Smoothing ussing gaussian kerbell
% 5: Expectations
The algorithm is written in matlab type, I add some comentaries in c style, I hope you can run it. I would like to explain it better, good luck.