I am using a function named cpselect (Image Processing Toolbox) which basically returns the pixel value (x,y) of the points I want in an image. The pixel value is then saved in workspace as a variable. So I have two problems:
function [] = ControlPoints()
%function that reads images in directory and uses cpselect to each
imagefiles = dir('*.jpg');
nfiles = length(imagefiles);
for ii=1:nfiles
currentfilename = imagefiles(ii).name;
currentimage = imread(currentfilename);
cpselect(currentimage,currentimage);
pause;
end
a = fixedPoints1; % returns error(undefined variable)
end
Is there a way of using these variables in the same function? They are created in the workspace, and not in the function itself, which is why I get errors when I try to use it.
thanks in advance
Both issues can be taken care of using the last syntax shown in the documentation:
[selectedMovingPoints,selectedFixedPoints] = cpselect(currentimage,currentimage,'Wait',true)
The returned arrays are p
x2 numeric arrays, where each row is one of the points selected.