Clear Filters
Clear Filters

Finding objects in images

5 views (last 30 days)
Tian Tian
Tian Tian on 24 Feb 2018
Commented: Tian Tian on 24 Feb 2018
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.

Accepted Answer

Image Analyst
Image Analyst on 24 Feb 2018
Maybe try braces T{n,'MeanIntensity'} instead of parentheses.
  1 Comment
Tian Tian
Tian Tian on 24 Feb 2018
Thank you so much! It worked perfectly!!

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!