Using regionprops to calculate the sum inside the ROI

9 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Image Analyst
Image Analyst il 26 Lug 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 Commenti
Aaron Smith
Aaron Smith il 8 Ago 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?

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by