MATLAB: Measuring intensity of immunostain per cell for all cells in a tissue section.

cell countcell intensityImage Processing Toolbox

Please see image above. It is a merge of red and blue channels but I do separate the channels to count. I tried using the blue_count and blue_final (because this is the image where I have eliminated unwanted parts for count) instead of blue_countfilled to find the intensity as you suggested, like this:
MeanIntensityValue = blue_count(blue_countfilled);
but it gave me the following error:
Subscript indices must either be real positive integers or logicals.
I also get an error when I tried this code:
CC = blue_countfilled;
stats = regionprops (CC,blue_count,'MinIntensity','MaxIntensity','MeanIntensity', 'PixelValues', 'Area');
T(end).stats = stats;
error message:
Error using regionprops>getPropsFromInput (line 1290)
PROPERTY must be a string.
Error in regionprops>ParseInputs (line 1244)
reqStats = getPropsFromInput(startIdxForProp, ...
Error in regionprops (line 205)
[I,requestedStats,officialStats] = ParseInputs(imageSize, argOffset, varargin{:});
I am using Matlab to count cells in a tissue section. I use the following code to count the cells:
-blue_count = bwconncomp(blue_final);
-blue_num = blue_count.NumObjects;
After counting, I am interested in measuring the intensity of pixels per cell (per area of the cell). First, I used imfill :
-blue_countfilled = imfill (blue_final, 'holes');
-figure, imshow (blue_countfilled)
-T(end). imfill = imfill(blue_final, 'holes');
The imfill in structure T gives an output of 1040x1392 double, inside this are all zeros
Then I tried a few things to try to get intensity value average for all the cells, first I used the following code:
-MeanIntensityValue = mean2(blue_countfilled);
-T(end).PixelIntensity = MeanIntensityValue;
This output gives a value of 0.0145 which I do not trust.
Then I tried the following code:
CC = blue_countfilled;
This gives an output of 1 each for MinIntensity, MaxIntensity, and MeanIntensity. It gives an output of 21041×1 for PixelValues, and an area value different from what it gave initially in pixels.
I am not sure what I am doing wrong but I need to analyze intensity of stain per cell for all cells in the tissue section. PLEASE HELP.

Best Answer

How can anyone help when you didn't attach your image?
blue_countfilled is a binary image so you don't want to take the mean of that, you need to get the mean of only the true parts of it.
MeanIntensityValue = blueImage(blue_countfilled);
You didn't show what blueImage is, but it's whatever you segmented to get the (badly-named) blue_final. That will give the average over all segmented pixels. If you want the blob-by-blob intensity, then you have to use regionprops() but you need to pass it blueImage, not blue_countfilled, like this:
stats = regionprops (CC, blueImage, 'MinIntensity', 'MaxIntensity', ...
'MeanIntensity', 'PixelValues', 'Area');
blobMeanIntensities = [stats.MeanIntensity]; % Extract from structure into double array.
Related Question