error indexing must appear last
3 views (last 30 days)
Show older comments
I have a code which tracks a series of footballs in a video.
I have found the coordinates for the balls in the video, and now I am trying to crop each of the larger images using the x and y coordinates of the balls.
However when I run the code to sub-image this, I get the error that indexing must appear last in an indexing expression. Can anybody help me solve this?
% Identify and track the particles for frames 1 and 2
for k = 1:numFrames;
%binarize frames 1 and 2 from the video (using rgb2gray)
frame_1 = rgb2gray(read(obj,k+start_frame-1));
frame_2 = rgb2gray(read(obj,k+start_frame));
%identify the circles in frames 1 and 2 with radii between the defined min and max
circles_1 =imfindcircles(frame_1,[min_radius,max_radius],'Sensitivity',quality,'Method','TwoStage');
circles_2 =imfindcircles(frame_2,[min_radius,max_radius],'Sensitivity',quality,'Method','TwoStage'); %returns the indicies of the closest points in the 2 vectors
% identifies where each circle has moved between frames 1 and 2
[index,dist] = dsearchn(circles_2,circles_1);
% here we have the distances not in order
% assign the circles from frames 1 and 2 to x and y coordinate variables
x_1{k} = circles_1(:,1);
x_2{k} = circles_2(index,1);
y_1{k} = circles_1(:,2);
y_2{k} = circles_2(index,2);
end
%% Crop frames 1 and 2 into sub-images from the coordinates of the circles
r = 10;
for k = 1:numFrames
%subimage the balls in frames 1 and 2 by shrinking them to the coordinates of the balls
subframe1 = frame_1(round(y_1)-r:round(y_1)+r)(round(x_1)-r:round(x_1)+r);
subframe2 = frame_2(round(y_2)-r:round(y_2)+r,round(x_2)-r:round(x_2)+r);
end
Error: ()-indexing must appear last in an index expression.
2 Comments
Walter Roberson
on 20 May 2020
subframe1 = frame_1(round(y_1)-r:round(y_1)+r, round(x_1)-r:round(x_1)+r);
Answers (0)
See Also
Categories
Find more on Colormaps 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!