error indexing must appear last

1 回表示 (過去 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 Center および File ExchangeGet 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