Finding objects in images

조회 수: 1 (최근 30일)
Tian Tian
Tian Tian 2018년 2월 24일
댓글: Tian Tian 2018년 2월 24일
I want to find objects with grayscale value <30. Now I am trying to write a table with all objects in excel file, then find and remove the row with a certain column value < 30, but there is always unexpected errors about my code.
T = stats;
excelfilename = 'Picture2.xlsx';
writetable(T,excelfilename,'Sheet',1,'Range','A1');
column=xlsread(excelfilename, 'A:A')
H=length(column)
for n = 1 : H
MeanIntensity(n)= T(n,'MeanIntensity')
if (MeanIntensity(n)<30)
% Intensity is < 30
mask = ismember(cc, n);
outputImage = I;
outputImage(~mask) = 0;
figure; % Bring up new figure
imshow(outputImage , []);
end
end
The error is "You cannot subscript a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts). Use a row subscript and a variable subscript." The error refers to H which is shown in a correct number but stopped running the rest code. I also tried 'height' and 'size' of the table to denote H, but none worked. Does anyone know where is the problem in my code? Thank you for your time in advance.

채택된 답변

Image Analyst
Image Analyst 2018년 2월 24일
Maybe try braces T{n,'MeanIntensity'} instead of parentheses.
  댓글 수: 1
Tian Tian
Tian Tian 2018년 2월 24일
Thank you so much! It worked perfectly!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by