error indexing must appear last

2 次查看(过去 30 天)
C.G.
C.G. 2020-5-20
编辑: C.G. 2020-5-20
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 个评论
Walter Roberson
Walter Roberson 2020-5-20
subframe1 = frame_1(round(y_1)-r:round(y_1)+r, round(x_1)-r:round(x_1)+r);
C.G.
C.G. 2020-5-20
编辑:C.G. 2020-5-20
Great, thank you that has worked.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by