error indexing must appear last

2 Ansichten (letzte 30 Tage)
C.G.
C.G. am 20 Mai 2020
Bearbeitet: C.G. am 20 Mai 2020
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 Kommentare
Walter Roberson
Walter Roberson am 20 Mai 2020
subframe1 = frame_1(round(y_1)-r:round(y_1)+r, round(x_1)-r:round(x_1)+r);
C.G.
C.G. am 20 Mai 2020
Bearbeitet: C.G. am 20 Mai 2020
Great, thank you that has worked.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Get Started with Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by