Detection Algorithm in 2D Images
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
%Kernel Gaussiano
kmu=   [0 0]'
ko=    [2 2]'
kSize= 15
vi= [1/ko(1) 0; 0 1/ko(2)].^2
kS=floor(kSize/2);
for i=-kS:1:kS
    for j=-kS:1:kS
       d=[i,j]'-kmu;
       g(1+i+kS,1+j+kS)=(1/((sqrt(2*pi))*(sqrt(det(vi)))))*exp(-0.5*d'*vi*d)
    end
end

% 1: Assum some initial conditions (umbrals, means, variances)

mu=[10 50 90 130 170 210] //My initial hypotesis of which color is each
                          //tissue
o= [ 5  5  5   5   5   5] //My initial hypotesis of how much varies each 
                          //tissue
E=[mu o] // My vector of results to stablish a stop criterion for the 
         // algorithm
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&gt;0.5 % e&lt;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
        T=(1/(sqrt(2*pi)*o(h)))*exp(-(0.5*(t-mu(h)).^2)/(o(h)*o(h)))
    end

% 2: Computing some likely hoods
    for h=1:length(mu)
        l(:,:,h)=(1/(sqrt(2*pi)*o(h)))*exp(-(0.5*(I-mu(h)).^2)/(o(h)*o(h)))
    end

% 3: Normalizing
    L=zeros(size(I))
    for h=1:length(mu)
        L=L+l(:,:,h)
    end
    for h=1:length(mu)
        p(:,:,h)=l(:,:,h)./L
    end

% 4: Smoothing ussing gaussian kerbell

    for h=1:length(mu)
       ps(:,:,h)=conv2(p(:,:,h),g,'same')
    end


    B=max(ps,[],3)
    for h=1:length(mu)
        b(:,:,h)=ps(:,:,h)==B
    end

% 5: Expectations

    for h=1:length(mu)
        aP(h)= 1/sum(sum(b(:,:,h)))
        mu(h)=aP(h)*sum(sum(I.*b(:,:,h)))
        o(h)=sqrt(aP(h)*sum(sum(((I-mu(h)).^2).*b(:,:,h))))
    end
    E=[mu o]
    e=sqrt((E-Ei)*(E-Ei)')

end


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.