MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

### Discover what MATLAB® can do for your career.

Subject: MeanIntensity

From: Aikerim

### Aikerim

Date: 20 Jul, 2011 19:04:09

Message: 1 of 16

Hello,
Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
I got these errors:
??? Error using ==> regionprops>ParseInputs at 1112
Size of I doesn't match size information found in the first input argument.

Error in ==> regionprops at 154
[I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});

Subject: MeanIntensity

From: Jeff

### Jeff EA

(Jeff)

Date: 20 Jul, 2011 19:43:09

Message: 2 of 16

"Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> Hello,
> Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> I got these errors:
> ??? Error using ==> regionprops>ParseInputs at 1112
> Size of I doesn't match size information found in the first input argument.
>
> Error in ==> regionprops at 154
> [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});

To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).

An example:
stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');

Subject: MeanIntensity

From: Aikerim

### Aikerim

Date: 20 Jul, 2011 20:04:10

Message: 3 of 16

"Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > Hello,
> > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > I got these errors:
> > ??? Error using ==> regionprops>ParseInputs at 1112
> > Size of I doesn't match size information found in the first input argument.
> >
> > Error in ==> regionprops at 154
> > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
>
> To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
>
> An example:
> stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');

I knew these thing,the function.I dont know what should I put instead of Intensity_image???
My code:

imshow(I);
threshold = graythresh(I);
bw = im2bw(I,threshold);

% remove all object containing fewer than 30 pixels
bw = bwareaopen(bw,180);

L=bwlabel(bw,8);
stats=regionprops(L, _______ ,'MeanIntensity');

Subject: MeanIntensity

From: Jeff

### Jeff EA

(Jeff)

Date: 20 Jul, 2011 23:05:25

Message: 4 of 16

"Aikerim" wrote in message <j07cbq\$214\$1@newscl01ah.mathworks.com>...
> "Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> > "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > > Hello,
> > > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > > I got these errors:
> > > ??? Error using ==> regionprops>ParseInputs at 1112
> > > Size of I doesn't match size information found in the first input argument.
> > >
> > > Error in ==> regionprops at 154
> > > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
> >
> > To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> > STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
> >
> > An example:
> > stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');
>
> I knew these thing,the function.I dont know what should I put instead of Intensity_image???
> My code:
>
> imshow(I);
> threshold = graythresh(I);
> bw = im2bw(I,threshold);
>
> % remove all object containing fewer than 30 pixels
> bw = bwareaopen(bw,180);
>
>
> L=bwlabel(bw,8);
> stats=regionprops(L, _______ ,'MeanIntensity');

In this context, regionprops requires a grayscale image. The easiest way to do this is to use RGB2GRAY, but there are other ways:

gray_img = rgb2gray(I);
L=bwlabel(bw, 8);
stats = regionprops(L, gray_img, 'MeanIntensity');

Subject: MeanIntensity

From: Aikerim

### Aikerim

Date: 21 Jul, 2011 08:36:09

Message: 5 of 16

"Jeff " <jea@gene.dot.com> wrote in message <j07mvl\$o8\$1@newscl01ah.mathworks.com>...
> "Aikerim" wrote in message <j07cbq\$214\$1@newscl01ah.mathworks.com>...
> > "Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> > > "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > > > Hello,
> > > > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > > > I got these errors:
> > > > ??? Error using ==> regionprops>ParseInputs at 1112
> > > > Size of I doesn't match size information found in the first input argument.
> > > >
> > > > Error in ==> regionprops at 154
> > > > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
> > >
> > > To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> > > STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
> > >
> > > An example:
> > > stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');
> >
> > I knew these thing,the function.I dont know what should I put instead of Intensity_image???
> > My code:
> >
> > imshow(I);
> > threshold = graythresh(I);
> > bw = im2bw(I,threshold);
> >
> > % remove all object containing fewer than 30 pixels
> > bw = bwareaopen(bw,180);
> >
> >
> > L=bwlabel(bw,8);
> > stats=regionprops(L, _______ ,'MeanIntensity');
>
> In this context, regionprops requires a grayscale image. The easiest way to do this is to use RGB2GRAY, but there are other ways:
>
> gray_img = rgb2gray(I);
> L=bwlabel(bw, 8);
> stats = regionprops(L, gray_img, 'MeanIntensity');

Hi,
But my image is already in grayscale I mean the original image (I)???

Subject: MeanIntensity

From: Jeff

### Jeff EA

(Jeff)

Date: 21 Jul, 2011 15:58:09

Message: 6 of 16

"Aikerim" wrote in message <j08odp\$jrq\$1@newscl01ah.mathworks.com>...
> "Jeff " <jea@gene.dot.com> wrote in message <j07mvl\$o8\$1@newscl01ah.mathworks.com>...
> > "Aikerim" wrote in message <j07cbq\$214\$1@newscl01ah.mathworks.com>...
> > > "Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> > > > "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > > > > Hello,
> > > > > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > > > > I got these errors:
> > > > > ??? Error using ==> regionprops>ParseInputs at 1112
> > > > > Size of I doesn't match size information found in the first input argument.
> > > > >
> > > > > Error in ==> regionprops at 154
> > > > > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
> > > >
> > > > To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> > > > STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
> > > >
> > > > An example:
> > > > stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');
> > >
> > > I knew these thing,the function.I dont know what should I put instead of Intensity_image???
> > > My code:
> > >
> > > I = imread('pvs6multiscale1j.jpg');
> > > imshow(I);
> > > threshold = graythresh(I);
> > > bw = im2bw(I,threshold);
> > >
> > > % remove all object containing fewer than 30 pixels
> > > bw = bwareaopen(bw,180);
> > >
> > >
> > > L=bwlabel(bw,8);
> > > stats=regionprops(L, _______ ,'MeanIntensity');
> >
> > In this context, regionprops requires a grayscale image. The easiest way to do this is to use RGB2GRAY, but there are other ways:
> >
> > gray_img = rgb2gray(I);
> > L=bwlabel(bw, 8);
> > stats = regionprops(L, gray_img, 'MeanIntensity');
>
> Hi,
> But my image is already in grayscale I mean the original image (I)???

Are you sure it is in grayscale, and not an RGB that looks like it is grayscale? Do one of two things:
1 - post the results of size(L) as well as size(I)

Subject: MeanIntensity

From: Aikerim

### Aikerim

Date: 21 Jul, 2011 16:20:10

Message: 7 of 16

"Jeff " <jea@gene.dot.com> wrote in message <j09iah\$3nd\$1@newscl01ah.mathworks.com>...
> "Aikerim" wrote in message <j08odp\$jrq\$1@newscl01ah.mathworks.com>...
> > "Jeff " <jea@gene.dot.com> wrote in message <j07mvl\$o8\$1@newscl01ah.mathworks.com>...
> > > "Aikerim" wrote in message <j07cbq\$214\$1@newscl01ah.mathworks.com>...
> > > > "Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> > > > > "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > > > > > Hello,
> > > > > > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > > > > > I got these errors:
> > > > > > ??? Error using ==> regionprops>ParseInputs at 1112
> > > > > > Size of I doesn't match size information found in the first input argument.
> > > > > >
> > > > > > Error in ==> regionprops at 154
> > > > > > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
> > > > >
> > > > > To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> > > > > STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
> > > > >
> > > > > An example:
> > > > > stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');
> > > >
> > > > I knew these thing,the function.I dont know what should I put instead of Intensity_image???
> > > > My code:
> > > >
> > > > I = imread('pvs6multiscale1j.jpg');
> > > > imshow(I);
> > > > threshold = graythresh(I);
> > > > bw = im2bw(I,threshold);
> > > >
> > > > % remove all object containing fewer than 30 pixels
> > > > bw = bwareaopen(bw,180);
> > > >
> > > >
> > > > L=bwlabel(bw,8);
> > > > stats=regionprops(L, _______ ,'MeanIntensity');
> > >
> > > In this context, regionprops requires a grayscale image. The easiest way to do this is to use RGB2GRAY, but there are other ways:
> > >
> > > gray_img = rgb2gray(I);
> > > L=bwlabel(bw, 8);
> > > stats = regionprops(L, gray_img, 'MeanIntensity');
> >
> > Hi,
> > But my image is already in grayscale I mean the original image (I)???
>
> Are you sure it is in grayscale, and not an RGB that looks like it is grayscale? Do one of two things:
> 1 - post the results of size(L) as well as size(I)

http://imageshack.us/photo/my-images/851/pvs6multiscale1j.jpg/

Subject: MeanIntensity

From: Jeff

### Jeff EA

(Jeff)

Date: 21 Jul, 2011 16:52:09

Message: 8 of 16

"Aikerim" wrote in message <j09jjq\$7n6\$1@newscl01ah.mathworks.com>...
> "Jeff " <jea@gene.dot.com> wrote in message <j09iah\$3nd\$1@newscl01ah.mathworks.com>...
> > "Aikerim" wrote in message <j08odp\$jrq\$1@newscl01ah.mathworks.com>...
> > > "Jeff " <jea@gene.dot.com> wrote in message <j07mvl\$o8\$1@newscl01ah.mathworks.com>...
> > > > "Aikerim" wrote in message <j07cbq\$214\$1@newscl01ah.mathworks.com>...
> > > > > "Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> > > > > > "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > > > > > > Hello,
> > > > > > > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > > > > > > I got these errors:
> > > > > > > ??? Error using ==> regionprops>ParseInputs at 1112
> > > > > > > Size of I doesn't match size information found in the first input argument.
> > > > > > >
> > > > > > > Error in ==> regionprops at 154
> > > > > > > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
> > > > > >
> > > > > > To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> > > > > > STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
> > > > > >
> > > > > > An example:
> > > > > > stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');
> > > > >
> > > > > I knew these thing,the function.I dont know what should I put instead of Intensity_image???
> > > > > My code:
> > > > >
> > > > > I = imread('pvs6multiscale1j.jpg');
> > > > > imshow(I);
> > > > > threshold = graythresh(I);
> > > > > bw = im2bw(I,threshold);
> > > > >
> > > > > % remove all object containing fewer than 30 pixels
> > > > > bw = bwareaopen(bw,180);
> > > > >
> > > > >
> > > > > L=bwlabel(bw,8);
> > > > > stats=regionprops(L, _______ ,'MeanIntensity');
> > > >
> > > > In this context, regionprops requires a grayscale image. The easiest way to do this is to use RGB2GRAY, but there are other ways:
> > > >
> > > > gray_img = rgb2gray(I);
> > > > L=bwlabel(bw, 8);
> > > > stats = regionprops(L, gray_img, 'MeanIntensity');
> > >
> > > Hi,
> > > But my image is already in grayscale I mean the original image (I)???
> >
> > Are you sure it is in grayscale, and not an RGB that looks like it is grayscale? Do one of two things:
> > 1 - post the results of size(L) as well as size(I)
>
> Could u try this link:
> http://imageshack.us/photo/my-images/851/pvs6multiscale1j.jpg/

Are you sure that's the right image? It looks like a binary mask displayed in matlab then saved.

In any case, the following code works with the image you provided:

imshow(I);
threshold = graythresh(I);
bw = im2bw(I,threshold);

% remove all object containing fewer than 30 pixels
bw = bwareaopen(bw,180);

L=bwlabel(bw,8);
stats=regionprops(L, I ,'MeanIntensity');

Subject: MeanIntensity

From: Aikerim

### Aikerim

Date: 21 Jul, 2011 17:07:09

Message: 9 of 16

"Jeff " <jea@gene.dot.com> wrote in message <j09lfp\$d69\$1@newscl01ah.mathworks.com>...
> "Aikerim" wrote in message <j09jjq\$7n6\$1@newscl01ah.mathworks.com>...
> > "Jeff " <jea@gene.dot.com> wrote in message <j09iah\$3nd\$1@newscl01ah.mathworks.com>...
> > > "Aikerim" wrote in message <j08odp\$jrq\$1@newscl01ah.mathworks.com>...
> > > > "Jeff " <jea@gene.dot.com> wrote in message <j07mvl\$o8\$1@newscl01ah.mathworks.com>...
> > > > > "Aikerim" wrote in message <j07cbq\$214\$1@newscl01ah.mathworks.com>...
> > > > > > "Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> > > > > > > "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > > > > > > > Hello,
> > > > > > > > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > > > > > > > I got these errors:
> > > > > > > > ??? Error using ==> regionprops>ParseInputs at 1112
> > > > > > > > Size of I doesn't match size information found in the first input argument.
> > > > > > > >
> > > > > > > > Error in ==> regionprops at 154
> > > > > > > > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
> > > > > > >
> > > > > > > To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> > > > > > > STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
> > > > > > >
> > > > > > > An example:
> > > > > > > stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');
> > > > > >
> > > > > > I knew these thing,the function.I dont know what should I put instead of Intensity_image???
> > > > > > My code:
> > > > > >
> > > > > > I = imread('pvs6multiscale1j.jpg');
> > > > > > imshow(I);
> > > > > > threshold = graythresh(I);
> > > > > > bw = im2bw(I,threshold);
> > > > > >
> > > > > > % remove all object containing fewer than 30 pixels
> > > > > > bw = bwareaopen(bw,180);
> > > > > >
> > > > > >
> > > > > > L=bwlabel(bw,8);
> > > > > > stats=regionprops(L, _______ ,'MeanIntensity');
> > > > >
> > > > > In this context, regionprops requires a grayscale image. The easiest way to do this is to use RGB2GRAY, but there are other ways:
> > > > >
> > > > > gray_img = rgb2gray(I);
> > > > > L=bwlabel(bw, 8);
> > > > > stats = regionprops(L, gray_img, 'MeanIntensity');
> > > >
> > > > Hi,
> > > > But my image is already in grayscale I mean the original image (I)???
> > >
> > > Are you sure it is in grayscale, and not an RGB that looks like it is grayscale? Do one of two things:
> > > 1 - post the results of size(L) as well as size(I)
> >
> > Could u try this link:
> > http://imageshack.us/photo/my-images/851/pvs6multiscale1j.jpg/
>
> Are you sure that's the right image? It looks like a binary mask displayed in matlab then saved.
>
> In any case, the following code works with the image you provided:
>
> imshow(I);
> threshold = graythresh(I);
> bw = im2bw(I,threshold);
>
> % remove all object containing fewer than 30 pixels
> bw = bwareaopen(bw,180);
>
> L=bwlabel(bw,8);
> stats=regionprops(L, I ,'MeanIntensity');
That's image is after the segmentation, it's my objective image,so it's strange it doesn't work on my Matlab (2009).It gives the mentioned before errors about 'not matching'...anyway,thank you!

Subject: MeanIntensity

From: Jeff

### Jeff EA

(Jeff)

Date: 21 Jul, 2011 18:13:09

Message: 10 of 16

"Aikerim" wrote in message <j09mbt\$g02\$1@newscl01ah.mathworks.com>...
> "Jeff " <jea@gene.dot.com> wrote in message <j09lfp\$d69\$1@newscl01ah.mathworks.com>...
> > "Aikerim" wrote in message <j09jjq\$7n6\$1@newscl01ah.mathworks.com>...
> > > "Jeff " <jea@gene.dot.com> wrote in message <j09iah\$3nd\$1@newscl01ah.mathworks.com>...
> > > > "Aikerim" wrote in message <j08odp\$jrq\$1@newscl01ah.mathworks.com>...
> > > > > "Jeff " <jea@gene.dot.com> wrote in message <j07mvl\$o8\$1@newscl01ah.mathworks.com>...
> > > > > > "Aikerim" wrote in message <j07cbq\$214\$1@newscl01ah.mathworks.com>...
> > > > > > > "Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> > > > > > > > "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > > > > > > > > Hello,
> > > > > > > > > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > > > > > > > > I got these errors:
> > > > > > > > > ??? Error using ==> regionprops>ParseInputs at 1112
> > > > > > > > > Size of I doesn't match size information found in the first input argument.
> > > > > > > > >
> > > > > > > > > Error in ==> regionprops at 154
> > > > > > > > > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
> > > > > > > >
> > > > > > > > To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> > > > > > > > STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
> > > > > > > >
> > > > > > > > An example:
> > > > > > > > stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');
> > > > > > >
> > > > > > > I knew these thing,the function.I dont know what should I put instead of Intensity_image???
> > > > > > > My code:
> > > > > > >
> > > > > > > I = imread('pvs6multiscale1j.jpg');
> > > > > > > imshow(I);
> > > > > > > threshold = graythresh(I);
> > > > > > > bw = im2bw(I,threshold);
> > > > > > >
> > > > > > > % remove all object containing fewer than 30 pixels
> > > > > > > bw = bwareaopen(bw,180);
> > > > > > >
> > > > > > >
> > > > > > > L=bwlabel(bw,8);
> > > > > > > stats=regionprops(L, _______ ,'MeanIntensity');
> > > > > >
> > > > > > In this context, regionprops requires a grayscale image. The easiest way to do this is to use RGB2GRAY, but there are other ways:
> > > > > >
> > > > > > gray_img = rgb2gray(I);
> > > > > > L=bwlabel(bw, 8);
> > > > > > stats = regionprops(L, gray_img, 'MeanIntensity');
> > > > >
> > > > > Hi,
> > > > > But my image is already in grayscale I mean the original image (I)???
> > > >
> > > > Are you sure it is in grayscale, and not an RGB that looks like it is grayscale? Do one of two things:
> > > > 1 - post the results of size(L) as well as size(I)
> > >
> > > Could u try this link:
> > > http://imageshack.us/photo/my-images/851/pvs6multiscale1j.jpg/
> >
> > Are you sure that's the right image? It looks like a binary mask displayed in matlab then saved.
> >
> > In any case, the following code works with the image you provided:
> >
> > imshow(I);
> > threshold = graythresh(I);
> > bw = im2bw(I,threshold);
> >
> > % remove all object containing fewer than 30 pixels
> > bw = bwareaopen(bw,180);
> >
> > L=bwlabel(bw,8);
> > stats=regionprops(L, I ,'MeanIntensity');
> That's image is after the segmentation, it's my objective image,so it's strange it doesn't work on my Matlab (2009).It gives the mentioned before errors about 'not matching'...anyway,thank you!

Sorry, I wasn't specific enough. Please post your original image, the one you are reading in the first step.

Subject: MeanIntensity

From: Aikerim

### Aikerim

Date: 21 Jul, 2011 18:25:10

Message: 11 of 16

"Jeff " <jea@gene.dot.com> wrote in message <j09q7l\$rje\$1@newscl01ah.mathworks.com>...
> "Aikerim" wrote in message <j09mbt\$g02\$1@newscl01ah.mathworks.com>...
> > "Jeff " <jea@gene.dot.com> wrote in message <j09lfp\$d69\$1@newscl01ah.mathworks.com>...
> > > "Aikerim" wrote in message <j09jjq\$7n6\$1@newscl01ah.mathworks.com>...
> > > > "Jeff " <jea@gene.dot.com> wrote in message <j09iah\$3nd\$1@newscl01ah.mathworks.com>...
> > > > > "Aikerim" wrote in message <j08odp\$jrq\$1@newscl01ah.mathworks.com>...
> > > > > > "Jeff " <jea@gene.dot.com> wrote in message <j07mvl\$o8\$1@newscl01ah.mathworks.com>...
> > > > > > > "Aikerim" wrote in message <j07cbq\$214\$1@newscl01ah.mathworks.com>...
> > > > > > > > "Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> > > > > > > > > "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > > > > > > > > > Hello,
> > > > > > > > > > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > > > > > > > > > I got these errors:
> > > > > > > > > > ??? Error using ==> regionprops>ParseInputs at 1112
> > > > > > > > > > Size of I doesn't match size information found in the first input argument.
> > > > > > > > > >
> > > > > > > > > > Error in ==> regionprops at 154
> > > > > > > > > > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
> > > > > > > > >
> > > > > > > > > To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> > > > > > > > > STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
> > > > > > > > >
> > > > > > > > > An example:
> > > > > > > > > stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');
> > > > > > > >
> > > > > > > > I knew these thing,the function.I dont know what should I put instead of Intensity_image???
> > > > > > > > My code:
> > > > > > > >
> > > > > > > > I = imread('pvs6multiscale1j.jpg');
> > > > > > > > imshow(I);
> > > > > > > > threshold = graythresh(I);
> > > > > > > > bw = im2bw(I,threshold);
> > > > > > > >
> > > > > > > > % remove all object containing fewer than 30 pixels
> > > > > > > > bw = bwareaopen(bw,180);
> > > > > > > >
> > > > > > > >
> > > > > > > > L=bwlabel(bw,8);
> > > > > > > > stats=regionprops(L, _______ ,'MeanIntensity');
> > > > > > >
> > > > > > > In this context, regionprops requires a grayscale image. The easiest way to do this is to use RGB2GRAY, but there are other ways:
> > > > > > >
> > > > > > > gray_img = rgb2gray(I);
> > > > > > > L=bwlabel(bw, 8);
> > > > > > > stats = regionprops(L, gray_img, 'MeanIntensity');
> > > > > >
> > > > > > Hi,
> > > > > > But my image is already in grayscale I mean the original image (I)???
> > > > >
> > > > > Are you sure it is in grayscale, and not an RGB that looks like it is grayscale? Do one of two things:
> > > > > 1 - post the results of size(L) as well as size(I)
> > > > > 2 - post your original image somewhere so we can download it and run it through your code
> > > >
> > > > Could u try this link:
> > > > http://imageshack.us/photo/my-images/851/pvs6multiscale1j.jpg/
> > >
> > > Are you sure that's the right image? It looks like a binary mask displayed in matlab then saved.
> > >
> > > In any case, the following code works with the image you provided:
> > >
> > > I = imread('pvs6multiscale1j.jpg');
> > > imshow(I);
> > > threshold = graythresh(I);
> > > bw = im2bw(I,threshold);
> > >
> > > % remove all object containing fewer than 30 pixels
> > > bw = bwareaopen(bw,180);
> > >
> > > L=bwlabel(bw,8);
> > > stats=regionprops(L, I ,'MeanIntensity');
> > That's image is after the segmentation, it's my objective image,so it's strange it doesn't work on my Matlab (2009).It gives the mentioned before errors about 'not matching'...anyway,thank you!
>
> Sorry, I wasn't specific enough. Please post your original image, the one you are reading in the first step.

http://imageshack.us/photo/my-images/825/pvs6.jpg/ here's an initial image before segmentation.but i should use the another one (in previous link)

Subject: MeanIntensity

From: Jeff

### Jeff EA

(Jeff)

Date: 21 Jul, 2011 19:25:11

Message: 12 of 16

"Aikerim" wrote in message <j09qu6\$m7\$1@newscl01ah.mathworks.com>...
> "Jeff " <jea@gene.dot.com> wrote in message <j09q7l\$rje\$1@newscl01ah.mathworks.com>...
> > "Aikerim" wrote in message <j09mbt\$g02\$1@newscl01ah.mathworks.com>...
> > > "Jeff " <jea@gene.dot.com> wrote in message <j09lfp\$d69\$1@newscl01ah.mathworks.com>...
> > > > "Aikerim" wrote in message <j09jjq\$7n6\$1@newscl01ah.mathworks.com>...
> > > > > "Jeff " <jea@gene.dot.com> wrote in message <j09iah\$3nd\$1@newscl01ah.mathworks.com>...
> > > > > > "Aikerim" wrote in message <j08odp\$jrq\$1@newscl01ah.mathworks.com>...
> > > > > > > "Jeff " <jea@gene.dot.com> wrote in message <j07mvl\$o8\$1@newscl01ah.mathworks.com>...
> > > > > > > > "Aikerim" wrote in message <j07cbq\$214\$1@newscl01ah.mathworks.com>...
> > > > > > > > > "Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> > > > > > > > > > "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > > > > > > > > > > Hello,
> > > > > > > > > > > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > > > > > > > > > > I got these errors:
> > > > > > > > > > > ??? Error using ==> regionprops>ParseInputs at 1112
> > > > > > > > > > > Size of I doesn't match size information found in the first input argument.
> > > > > > > > > > >
> > > > > > > > > > > Error in ==> regionprops at 154
> > > > > > > > > > > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
> > > > > > > > > >
> > > > > > > > > > To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> > > > > > > > > > STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
> > > > > > > > > >
> > > > > > > > > > An example:
> > > > > > > > > > stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');
> > > > > > > > >
> > > > > > > > > I knew these thing,the function.I dont know what should I put instead of Intensity_image???
> > > > > > > > > My code:
> > > > > > > > >
> > > > > > > > > I = imread('pvs6multiscale1j.jpg');
> > > > > > > > > imshow(I);
> > > > > > > > > threshold = graythresh(I);
> > > > > > > > > bw = im2bw(I,threshold);
> > > > > > > > >
> > > > > > > > > % remove all object containing fewer than 30 pixels
> > > > > > > > > bw = bwareaopen(bw,180);
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > L=bwlabel(bw,8);
> > > > > > > > > stats=regionprops(L, _______ ,'MeanIntensity');
> > > > > > > >
> > > > > > > > In this context, regionprops requires a grayscale image. The easiest way to do this is to use RGB2GRAY, but there are other ways:
> > > > > > > >
> > > > > > > > gray_img = rgb2gray(I);
> > > > > > > > L=bwlabel(bw, 8);
> > > > > > > > stats = regionprops(L, gray_img, 'MeanIntensity');
> > > > > > >
> > > > > > > Hi,
> > > > > > > But my image is already in grayscale I mean the original image (I)???
> > > > > >
> > > > > > Are you sure it is in grayscale, and not an RGB that looks like it is grayscale? Do one of two things:
> > > > > > 1 - post the results of size(L) as well as size(I)
> > > > > > 2 - post your original image somewhere so we can download it and run it through your code
> > > > >
> > > > > Could u try this link:
> > > > > http://imageshack.us/photo/my-images/851/pvs6multiscale1j.jpg/
> > > >
> > > > Are you sure that's the right image? It looks like a binary mask displayed in matlab then saved.
> > > >
> > > > In any case, the following code works with the image you provided:
> > > >
> > > > I = imread('pvs6multiscale1j.jpg');
> > > > imshow(I);
> > > > threshold = graythresh(I);
> > > > bw = im2bw(I,threshold);
> > > >
> > > > % remove all object containing fewer than 30 pixels
> > > > bw = bwareaopen(bw,180);
> > > >
> > > > L=bwlabel(bw,8);
> > > > stats=regionprops(L, I ,'MeanIntensity');
> > > That's image is after the segmentation, it's my objective image,so it's strange it doesn't work on my Matlab (2009).It gives the mentioned before errors about 'not matching'...anyway,thank you!
> >
> > Sorry, I wasn't specific enough. Please post your original image, the one you are reading in the first step.
>
> http://imageshack.us/photo/my-images/825/pvs6.jpg/ here's an initial image before segmentation.but i should use the another one (in previous link)

Huh. Well, I don't understand why you need the mean intensity of a binary mask image (your pv6multiscale). The "mean intensity" of a binary mask would always be 1, or 255, or whatever value is assigned to the white pixels, no matter what shape the region is...unless the mask has holes it in, which yours does not.
Typically, one would create a binary mask and then use that to determine the mean intensity in the original image. If this is what you are interested in, try the following:

threshold = graythresh(I);
bw = ~im2bw(I,threshold);
bw = imfill(bw, 'holes');

% remove all object containing fewer than 30 pixels
bw = bwareaopen(bw,180);

L=bwlabel(bw,8);
stats=regionprops(L, I ,'MeanIntensity');

If this is not what you're interested in, you'll need to be a bit more specific.

Subject: MeanIntensity

From: Aikerim

### Aikerim

Date: 21 Jul, 2011 19:41:09

Message: 13 of 16

"Jeff " <jea@gene.dot.com> wrote in message <j09uen\$bcd\$1@newscl01ah.mathworks.com>...
> "Aikerim" wrote in message <j09qu6\$m7\$1@newscl01ah.mathworks.com>...
> > "Jeff " <jea@gene.dot.com> wrote in message <j09q7l\$rje\$1@newscl01ah.mathworks.com>...
> > > "Aikerim" wrote in message <j09mbt\$g02\$1@newscl01ah.mathworks.com>...
> > > > "Jeff " <jea@gene.dot.com> wrote in message <j09lfp\$d69\$1@newscl01ah.mathworks.com>...
> > > > > "Aikerim" wrote in message <j09jjq\$7n6\$1@newscl01ah.mathworks.com>...
> > > > > > "Jeff " <jea@gene.dot.com> wrote in message <j09iah\$3nd\$1@newscl01ah.mathworks.com>...
> > > > > > > "Aikerim" wrote in message <j08odp\$jrq\$1@newscl01ah.mathworks.com>...
> > > > > > > > "Jeff " <jea@gene.dot.com> wrote in message <j07mvl\$o8\$1@newscl01ah.mathworks.com>...
> > > > > > > > > "Aikerim" wrote in message <j07cbq\$214\$1@newscl01ah.mathworks.com>...
> > > > > > > > > > "Jeff " <jea@gene.dot.com> wrote in message <j07b4d\$rj9\$1@newscl01ah.mathworks.com>...
> > > > > > > > > > > "Aikerim" wrote in message <j078r9\$kbe\$1@newscl01ah.mathworks.com>...
> > > > > > > > > > > > Hello,
> > > > > > > > > > > > Could someone provide me with an example (code) of meanintensity finding.I should calculate the mean object intensity in the range 0-100. I've tried regionprops (L,I,'MeanIntensity') , how to understand that size (I) must to be equal size (L) how to write or set it?
> > > > > > > > > > > > I got these errors:
> > > > > > > > > > > > ??? Error using ==> regionprops>ParseInputs at 1112
> > > > > > > > > > > > Size of I doesn't match size information found in the first input argument.
> > > > > > > > > > > >
> > > > > > > > > > > > Error in ==> regionprops at 154
> > > > > > > > > > > > [I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
> > > > > > > > > > >
> > > > > > > > > > > To calculate mean intensity, regionprops needs the raw image in addition to a labeled or binary image:
> > > > > > > > > > > STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).
> > > > > > > > > > >
> > > > > > > > > > > An example:
> > > > > > > > > > > stats = regionprops(BW_image, Intensity_image, 'MeanIntensity');
> > > > > > > > > >
> > > > > > > > > > I knew these thing,the function.I dont know what should I put instead of Intensity_image???
> > > > > > > > > > My code:
> > > > > > > > > >
> > > > > > > > > > I = imread('pvs6multiscale1j.jpg');
> > > > > > > > > > imshow(I);
> > > > > > > > > > threshold = graythresh(I);
> > > > > > > > > > bw = im2bw(I,threshold);
> > > > > > > > > >
> > > > > > > > > > % remove all object containing fewer than 30 pixels
> > > > > > > > > > bw = bwareaopen(bw,180);
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > L=bwlabel(bw,8);
> > > > > > > > > > stats=regionprops(L, _______ ,'MeanIntensity');
> > > > > > > > >
> > > > > > > > > In this context, regionprops requires a grayscale image. The easiest way to do this is to use RGB2GRAY, but there are other ways:
> > > > > > > > >
> > > > > > > > > gray_img = rgb2gray(I);
> > > > > > > > > L=bwlabel(bw, 8);
> > > > > > > > > stats = regionprops(L, gray_img, 'MeanIntensity');
> > > > > > > >
> > > > > > > > Hi,
> > > > > > > > But my image is already in grayscale I mean the original image (I)???
> > > > > > >
> > > > > > > Are you sure it is in grayscale, and not an RGB that looks like it is grayscale? Do one of two things:
> > > > > > > 1 - post the results of size(L) as well as size(I)
> > > > > > > 2 - post your original image somewhere so we can download it and run it through your code
> > > > > >
> > > > > > Could u try this link:
> > > > > > http://imageshack.us/photo/my-images/851/pvs6multiscale1j.jpg/
> > > > >
> > > > > Are you sure that's the right image? It looks like a binary mask displayed in matlab then saved.
> > > > >
> > > > > In any case, the following code works with the image you provided:
> > > > >
> > > > > I = imread('pvs6multiscale1j.jpg');
> > > > > imshow(I);
> > > > > threshold = graythresh(I);
> > > > > bw = im2bw(I,threshold);
> > > > >
> > > > > % remove all object containing fewer than 30 pixels
> > > > > bw = bwareaopen(bw,180);
> > > > >
> > > > > L=bwlabel(bw,8);
> > > > > stats=regionprops(L, I ,'MeanIntensity');
> > > > That's image is after the segmentation, it's my objective image,so it's strange it doesn't work on my Matlab (2009).It gives the mentioned before errors about 'not matching'...anyway,thank you!
> > >
> > > Sorry, I wasn't specific enough. Please post your original image, the one you are reading in the first step.
> >
> > http://imageshack.us/photo/my-images/825/pvs6.jpg/ here's an initial image before segmentation.but i should use the another one (in previous link)
>
> Huh. Well, I don't understand why you need the mean intensity of a binary mask image (your pv6multiscale). The "mean intensity" of a binary mask would always be 1, or 255, or whatever value is assigned to the white pixels, no matter what shape the region is...unless the mask has holes it in, which yours does not.
> Typically, one would create a binary mask and then use that to determine the mean intensity in the original image. If this is what you are interested in, try the following:
>
> threshold = graythresh(I);
> bw = ~im2bw(I,threshold);
> bw = imfill(bw, 'holes');
>
> % remove all object containing fewer than 30 pixels
> bw = bwareaopen(bw,180);
>
> L=bwlabel(bw,8);
> stats=regionprops(L, I ,'MeanIntensity');
>
> If this is not what you're interested in, you'll need to be a bit more specific.

Thank you Jeff so much, I understand all these things but that's a task 'to find the mean object intensity in the range 0-100':)so...Thank you!!!

 Subject: MeanIntensity From: ImageAnalyst Date: 23 Jul, 2011 22:13:20 Message: 14 of 16 On Jul 21, 3:41 pm, "Aikerim " wrote: > Thank you Jeff so much, I understand all these things but that's a task 'to find the mean object intensity in the range 0-100':)so...Thank you!!! --------------------------------------------------------------------- Aikerim : What do you mean by "that's a task"? Do you mean "it is difficult for me"? Or do you mean "My assigned task is to find...."? Or something else? What do you mean by "find the mean object intensity in the range 0-100"? This seems to be a new criteria you just added. You didn't mention anything about the 0-100 range before. This should be a trivial problem, even with the new "0-100" requirement, especially with the code Jeff gave you. And getting back to your original question, how on earth did your original and labeled image get to have different sizes like the error message indicated? Do you have this problem solved yet or not? Your last post is unclear on that. ImageAnalyst

Subject: MeanIntensity

From: Aikerim

### Aikerim

Date: 24 Jul, 2011 10:35:08

Message: 15 of 16

> On Jul 21, 3:41 pm, "Aikerim " <keri...@mail.ru> wrote:
> > Thank you Jeff so much, I understand all these things but that's a task 'to find the mean object intensity in the range 0-100':)so...Thank you!!!
> ---------------------------------------------------------------------
> Aikerim :
> What do you mean by "that's a task"? Do you mean "it is difficult for
> me"? Or do you mean "My assigned task is to find...."? Or something
> else?
>
> What do you mean by "find the mean object intensity in the range
> 0-100"? This seems to be a new criteria you just added. You didn't
> mention anything about the 0-100 range before. This should be a
> trivial problem, even with the new "0-100" requirement, especially
> with the code Jeff gave you.
>
> And getting back to your original question, how on earth did your
> original and labeled image get to have different sizes like the error
> message indicated?
>
> Do you have this problem solved yet or not? Your last post is unclear
> on that.
> ImageAnalyst
Hi,
The initially assigned task is to find the mean intensity (0-100),I understood that 0-100 is percentage if e.g the intensity is from 0 to 255, I should find the percentage of it.
Unfortunately, I couldnt get any results using the original image with the code. There are still the mentioned errors .I dont know whats a problem,if Jeff said that the code works. Maybe with Matlab or PC,I've tried to restart Matlab...but anyway no changes.