1
$\begingroup$

Suppose there is a two-deimensional image which consists of pixels. In every pixel, there are 0 to n apples with different colors, which can be digitalized(e.g.[0,10000]).

So we can plot a histogram for the color distribution of apples in every pixel. Some color may be more significant in this histogram. Let's call them color bumps.

The image below is for one pixel. histogram How to detect areas (they also consist of pixels ) with a particular color bump? In this kind of areas, apples in color channel, say [0.2,0.5] are more significant than apples in other channels.

The shape of an area is irregular generally. We can set color channel we are interested in and the lower limit of significane.

My idea is:

We need to find a pixel as a seed, let it grow, and set criteria to find the boundary where a growth stops.

Or we find pixels one by one, then connect pixels to from a continuous area.

Which kind of algorithm is good at this? You have ever met this kind of example in practise?

$\endgroup$
  • $\begingroup$ Can you clarify what you are displaying in the image? It sounds like it's the "average" (combined) color of all points in a part of some other image (and you are calling that part a "grid") ? $\endgroup$ – Peter K. Dec 3 '15 at 17:25
  • $\begingroup$ @Peter it is clearer now? $\endgroup$ – questionhang Dec 3 '15 at 17:54
  • $\begingroup$ What do you mean when you say: "In everypixel, there are 0 to n points"? $\endgroup$ – Alexander Leon VI Dec 4 '15 at 4:17
  • $\begingroup$ By color band do you mean red, blue and green? or also other colors? $\endgroup$ – Alexander Leon VI Dec 4 '15 at 4:18
  • $\begingroup$ You need to add the scale that you are using, and how you are asigning the colors to that image and what color space are you using. When You said that the picture posted has colors from 1 to 2, that´s not true since you said you were working with 3 channels. If you are using 3 channels you need a vector of 3 elements to say the color of a pixel. $\endgroup$ – Alexander Leon VI Dec 4 '15 at 4:22
2
$\begingroup$

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:

enter image description here

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:

enter image description here

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>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
        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.

$\endgroup$
  • $\begingroup$ could you please say more about "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."? For example, could you plese explain one upper figure and its corresponding lower figure? $\endgroup$ – questionhang Dec 6 '15 at 11:21
  • $\begingroup$ Yep!, let's take the first pair of images which represent the region where there isn't any tissue. In the upper image you can see the probability of all the pixels that aren't a tissue, high probabilities are represented by white while low probabilities are darker. In the other image a process of binarization was applied in order to show all the pixels classified as no-tissue regions $\endgroup$ – Alexander Leon VI Dec 6 '15 at 11:48
  • $\begingroup$ so for me, I need to calculate a valur for every pixel, which corresponds the 1st image. Then in order to search for interesting areas, I need to run binarization to get the second image, right? A second question is, why the two images are very similar? $\endgroup$ – questionhang Dec 6 '15 at 13:41
  • $\begingroup$ I have no idea of how handle your case. In the example that I posted I am assuming that a single pixel has a set of probabilities of being any of the six types of tissue. In this case I am assuming six types of tissue: 1. No tissue, 2. Cefalorraquideous liquid, 3. Gray matter, 4. White matter, 5. Skull and 6. Skin. Now, if we take a look of the probabilities of one pixel in the corner, we know in advance that this pixel corresponds to the non-tissue region, so the probabilities for the six types of tissue may look similar to [0.95, 0.01, 0.01, 0.01, 0.01, 0.01] and the sum of all the probabi $\endgroup$ – Alexander Leon VI Dec 6 '15 at 15:14
  • $\begingroup$ probabilities shoul be one. Now if we look one of the pixels that belongs to the no-tissue region, but is near to the skin, the probabilities may look like [0.7, 0.01, 0.01, 0.01, 0.01, 0.26] now, that pixel has a high probability of being a not a tissue, but the pixel also has a considerable probability of being skin. So we need to establish a criterion for this pixel to say if it is or not a certain kind of tissue. This is the purpose of binarization. A white pixel in the second image shows that the pixel has been labeled as a pixel that belongs to the region in question. $\endgroup$ – Alexander Leon VI Dec 6 '15 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.