Using regionprops to calculate the sum inside the ROI

9 vues (au cours des 30 derniers jours)
Aaron Smith
Aaron Smith le 26 Juil 2017
Commenté : Aaron Smith le 8 Août 2017
I have a logical mask with several regions of interest. I need to calculate the total intensity inside each of the regions of interest. I know that the max, min and mean intensities can be calculated but is it possible to calculate the sum. I am also applying this mask to a number of other matrices. My goal is to be able to compare the sum of each region for the different matrices and tabulate the data to show the differences between the regions and from matrix to matrix.

Réponse acceptée

Image Analyst
Image Analyst le 26 Juil 2017
Of course. Just ask regionprops() for the area and MeanIntensity and multiply them.
props = regionprops(labeledImage, grayImage, 'Area', 'MeanIntensity');
% Get the areas of all blobs.
allAreas = [props.Area];
% Get the mean intensities of all blobs.
allMeans = [props.MeanIntensity];
% Get the integrated gray level of all blobs.
allIGLs = allAreas .* allMeans;
  4 commentaires
Aaron Smith
Aaron Smith le 27 Juil 2017
Thanks so much!
Aaron Smith
Aaron Smith le 8 Août 2017
I tried using this code:
Y = handles.finishCell;
for i = 1 : length(Y)
thisImage = Y(i); % Extract matrix from your cell array of matrices.
% Get allIGLs for that image using other code I gave.
props = regionprops(labeledImage, thisImage, 'Area', 'MeanIntensity');
allAreas = [props.Area];
allMeans = [props.MeanIntensity];
allIGLs = allAreas .* allMeans;
caIGLs{i} = allIGLs; % Store IGLs for this image into a cell array.
end
And got the following error:
Error using regionprops>getPropsFromInput (line 1179)
PROPERTY must be a string.
Error in regionprops>ParseInputs (line 1133)
reqStats = getPropsFromInput(startIdxForProp, ...
Error in regionprops (line 154)
[I,requestedStats,officialStats] = ParseInputs(imageSize, varargin{:});
Error in hopefully_the_last_window>pushbutton3_Callback (line 190)
props = regionprops(labeledImage, thisImage, 'Area', 'MeanIntensity');
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in hopefully_the_last_window (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)hopefully_the_last_window('pushbutton3_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I had previously used this code to apply my mask to the matrices in my cell array:
mask = labeledImage;
Y = handles.finishCell;
for i = 1 : numel(Y)
X = Y{i}.*mask;
end
Can I simply calculate the mean intensity of the three different ROI for each of the cells in this new cell array?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by