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 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