From: Digistar You on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <8584e437-20cf-48bc-a411-b11c260b28b0(a)u31g2000yqb.googlegroups.com>...
> On Apr 8, 4:11 pm, "Digistar You" <digistar2...(a)163.com> wrote:
> > Dear all,
> >
> > I had divided an image into different regions and label each region. For each region, I want to find which regions are neighboring to it, i.e. a region shares the same boundary with the target region, and how many pixels on the shared boundary. I tried to write a program, which can give me the answer, however, it run very very slowly. Because I calculated the distance between any two pixels in two regions. Is there any MATLAB toolbox function that can do this job? Or could you please tell me a fast approach to find out the neighboring regions? Thank you very much.
> >
> > Best regards,
> >
> > Jason
>
> ----------------------------------------------------------------------------------
> Yes, run graycomatrix() on the labeled image.

Thanks a lot. But I studied this function but it is still not clear to me. Could you please give me an example on how to run graycomatrix() on a labeled image, given a matrix L whose elements are labels of an image? Thank you very much.
From: ImageAnalyst on
On Apr 8, 4:50 pm, "Digistar You" <digistar2...(a)163.com> wrote:
> ImageAnalyst <imageanal...(a)mailinator.com> wrote in message <8584e437-20cf-48bc-a411-b11c260b2...(a)u31g2000yqb.googlegroups.com>...
> > On Apr 8, 4:11 pm, "Digistar You" <digistar2...(a)163.com> wrote:
> > > Dear all,
>
> > > I had divided an image into different regions and label each region. For each region, I want to find which regions are neighboring to it, i.e. a region shares the same boundary with the target region, and how many pixels on the shared boundary. I tried to write a program, which can give me the answer, however, it run very very slowly. Because I calculated the distance between any two pixels in two regions. Is there any MATLAB toolbox function that can do this job? Or could you please tell me a fast approach to find out the neighboring regions? Thank you very much.
>
> > > Best regards,
>
> > > Jason
>
> > ---------------------------------------------------------------------------­-------
> > Yes, run graycomatrix() on the labeled image.
>
> Thanks a lot. But I studied this function but it is still not clear to me.. Could you please give me an example on how to run graycomatrix() on a labeled image, given a matrix L whose elements are labels of an image? Thank you very much.

-----------------------------------------------------------------------------------
A labeled image has numbers for each blob: 1,2,3,4,5 etc. one number
for each and every blob. The gray level co-occurrence matrix lets you
look out a specified distance from each pixel and identify gray levels
(blob numbers) that occur. Thus if you want to look out, say, 5
pixels, and you're in a pixel for blob #2 and it sees gray levels of
8, 13, and 20, then that means that blobs 8, 13, and 20 are within 5
pixels of blob #2. The GLCM is an array of N by N where N is the
number of blobs (gray levels) in the image. If one blob neighbors
another, there will be a non-zero value in the row and column
corresponding to those two blobs.
From: Digistar You on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <46e5d62d-eeb7-4a73-8f3b-1c3ca3968db7(a)r27g2000yqn.googlegroups.com>...
> On Apr 8, 4:50 pm, "Digistar You" <digistar2...(a)163.com> wrote:
> > ImageAnalyst <imageanal...(a)mailinator.com> wrote in message <8584e437-20cf-48bc-a411-b11c260b2...(a)u31g2000yqb.googlegroups.com>...
> > > On Apr 8, 4:11 pm, "Digistar You" <digistar2...(a)163.com> wrote:
> > > > Dear all,
> >
> > > > I had divided an image into different regions and label each region. For each region, I want to find which regions are neighboring to it, i.e. a region shares the same boundary with the target region, and how many pixels on the shared boundary. I tried to write a program, which can give me the answer, however, it run very very slowly. Because I calculated the distance between any two pixels in two regions. Is there any MATLAB toolbox function that can do this job? Or could you please tell me a fast approach to find out the neighboring regions? Thank you very much.
> >
> > > > Best regards,
> >
> > > > Jason
> >
> > > ---------------------------------------------------------------------------­-------
> > > Yes, run graycomatrix() on the labeled image.
> >
> > Thanks a lot. But I studied this function but it is still not clear to me. Could you please give me an example on how to run graycomatrix() on a labeled image, given a matrix L whose elements are labels of an image? Thank you very much.
>
> -----------------------------------------------------------------------------------
> A labeled image has numbers for each blob: 1,2,3,4,5 etc. one number
> for each and every blob. The gray level co-occurrence matrix lets you
> look out a specified distance from each pixel and identify gray levels
> (blob numbers) that occur. Thus if you want to look out, say, 5
> pixels, and you're in a pixel for blob #2 and it sees gray levels of
> 8, 13, and 20, then that means that blobs 8, 13, and 20 are within 5
> pixels of blob #2. The GLCM is an array of N by N where N is the
> number of blobs (gray levels) in the image. If one blob neighbors
> another, there will be a non-zero value in the row and column
> corresponding to those two blobs.

Thank you so much for the detailed explanation. However, my MATLAB seems to run strangely. For example, I have a labels image matrix L (256*256) which contains 45 regions (region labels ranging from 1-45), i.e. the pixel values of L range from 1-45. If I used GLCM=graycomatrix(L), it returned a 8-by-8 matrix, and all elements of this matrix are equal to 0, except for the element (8,8). In addition, I tested the example as in the help doc.
Let I=[1 1 5 6 8
2 3 5 7 1
4 5 7 1 2
8 5 1 2 5],
GLCM=graycomatrix(I).
Then GLCM = [0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 16].
What was wrong with it? Or should I change some parameters?
From: Digistar You on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <46e5d62d-eeb7-4a73-8f3b-1c3ca3968db7(a)r27g2000yqn.googlegroups.com>...
> On Apr 8, 4:50 pm, "Digistar You" <digistar2...(a)163.com> wrote:
> > ImageAnalyst <imageanal...(a)mailinator.com> wrote in message <8584e437-20cf-48bc-a411-b11c260b2...(a)u31g2000yqb.googlegroups.com>...
> > > On Apr 8, 4:11 pm, "Digistar You" <digistar2...(a)163.com> wrote:
> > > > Dear all,
> >
> > > > I had divided an image into different regions and label each region. For each region, I want to find which regions are neighboring to it, i.e. a region shares the same boundary with the target region, and how many pixels on the shared boundary. I tried to write a program, which can give me the answer, however, it run very very slowly. Because I calculated the distance between any two pixels in two regions. Is there any MATLAB toolbox function that can do this job? Or could you please tell me a fast approach to find out the neighboring regions? Thank you very much.
> >
> > > > Best regards,
> >
> > > > Jason
> >
> > > ---------------------------------------------------------------------------­-------
> > > Yes, run graycomatrix() on the labeled image.
> >
> > Thanks a lot. But I studied this function but it is still not clear to me. Could you please give me an example on how to run graycomatrix() on a labeled image, given a matrix L whose elements are labels of an image? Thank you very much.
>
> -----------------------------------------------------------------------------------
> A labeled image has numbers for each blob: 1,2,3,4,5 etc. one number
> for each and every blob. The gray level co-occurrence matrix lets you
> look out a specified distance from each pixel and identify gray levels
> (blob numbers) that occur. Thus if you want to look out, say, 5
> pixels, and you're in a pixel for blob #2 and it sees gray levels of
> 8, 13, and 20, then that means that blobs 8, 13, and 20 are within 5
> pixels of blob #2. The GLCM is an array of N by N where N is the
> number of blobs (gray levels) in the image. If one blob neighbors
> another, there will be a non-zero value in the row and column
> corresponding to those two blobs.

Hi, thank you. I guess I get it now. I tried to use: [glcm,SI] = graycomatrix(labels,'NumLevels',45,'G',[]). I think glcm should give the correct answer, and I will validate it. Thank you very much.