index out of bound in matlab : picking up similar matching points in 2 matlab images
1 view (last 30 days)
Show older comments
i am doing a program, in which i have 2 images and i have to find matches in them. now when i run this code, it shows the point match but is showing an error. due to this error, my code cannot proceed further to the next part of the code.
my code is
%%Read in two images
imgl = imread('pic410.bmp');
imgr = imread('pic430.bmp');
%%display image pair side by side
[ROWS, COLS, CHANNELS] = size(imgl);
disimg = [imgl imgr];
image(disimg);
% You can change these two numbers,
% but use the variables; I will use them
% to load my data to test your algorithms
% Total Number of control points
Nc = 15;
% Total Number of test points
Nt = 4;
%%After several runs, you may want to save the point matches
%%in files (see below and then load them here, instead of
%%clicking many point matches every time you run the program
load pl.mat pl;
%load pr.mat pr;
%%interface for picking up both the control points and
%%the test points
cnt = 1;
hold;
while(cnt <= Nc+Nt)
%%size of the rectangle to indicate point locations
dR = 50;
dC = 50;
%%pick up a point in the left image and display it with a rectangle....
%%%if you loaded the point matches, comment the point picking up (3 lines)%%%
%[X, Y] = ginput(1);
%Cl = X(1); Rl = Y(1);
%pl(cnt,:) = [Cl Rl 1];
%CANNOT COMMENT THIS BELOW 2-3 LINES
%%and draw it
Cl= pl(cnt,1); Rl=pl(cnt,2);
rectangle('Curvature', [0 0], 'Position', [Cl Rl dC dR]);
%%and then pick up the correspondence in the right image
%%%if you loaded the point matches, comment the point picking up (three lines)%%%
%[X, Y] = ginput(1);
%Cr = X(1); Rr = Y(1);
%pr(cnt,:) = [Cr-COLS Rr 1];
%CANOT COMMENT THESE BELOW 2-3 LINES
%%draw it
Cr=pr(cnt,1)+COLS; Rr=pr(cnt,2);
rectangle('Curvature', [0 0], 'Position', [Cr Rr dC dR]);
plot(Cr+COLS,Rr,'r*');
drawnow;
cnt = cnt+1;
end
the error is
Attempted to access pl(12,1); index out of bounds because size(pl)=[11,3].
Error in FmatGUI_2 (line 45)
Cl= pl(cnt,1); Rl=pl(cnt,2);
if i disable these lines, then i cannot see the image. so i have to keep these lines without the error. please let me know how to solve this problem.
0 Comments
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!