PROPERTY must be a string error using regionprops
조회 수: 4 (최근 30일)
이전 댓글 표시
I am using regionprops to calculate the mean intensity inside three regions of interest on a a number of matrices.
while again
thisRegion = roipoly;
% Add this in to the main one
finalImage = finalImage | thisRegion;
promptMessage = sprintf('Do you want to add another region?');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Yes', 'No', 'Yes');
if strcmpi(buttonText, 'No')
again = false;
end
labeledImage = logical(finalImage);
end
mask = labeledImage;
Y = handles.finishCell;
for i = 1 : length(Y)
thisImage = Y(i); % Extract matrix from cell array of matrices.
%Get allIGLs for that image.
props = regionprops(mask, 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
The last time I tried this code it did not generate an error and then I tried using the GUI again, having run it again and a very long series of errors arose. Matlab also stopped responding to some commands. I restarted Matlab and ran the code again. This time this error occurred:
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 196)
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 am not sure if this is due to the inputs (the logical mask and the cell array) or something else. In the code itself, the variable caIGLs has an attention underline stating that the variable appears to change size on every loop iteration. Consider preallocating for speed.
Each of the matrices in the cell array are the same size so I'm not sure how the final variable caIGLs can change each time.
댓글 수: 0
채택된 답변
Image Analyst
2017년 8월 9일
You're getting a cell. You need to get the CONTENTS of the cell, which is presumably your image, so use braces not parentheses:
thisImage = Y{i};
See the FAQ for a good intuitive discussion of what a cell and cell array are: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!