So im trying to make a loop for my ginput in matlab, i have the following code:
jpgFiles = dir('*.jpg');
numFiles = length(jpgFiles);
mydata = cell(1,numFiles);
% mydata = zeros(numFiles);
for k = 1:numFiles
mydata{1,k} = imread(jpgFiles(k).name);
end
for k = 1:numFiles
% subplot(4,5,k);
figure;
imshow(mydata{k});
[x, y] = ginput(30)
end
and i would like to get [x, y] into a matrix 30x6 (30 points and 6 images) i have tryed making a for-loop and a function like xx=x(k) but i make it work. Can someone help me do that since it would save me a lot of time for my analysis. Im a newbie to matlab so hope you guys can help me since i can't seem to find a useable answer on matworks.com
Mikkel - rather than a 30x6 matrix of points, perhaps visualize it as a 30x2x6 three-dimensional matrix. Remember, that your x and y are 30x1 column arrays and so "putting" them together would give us a 30x2 matrix. And then for your six images, this would 30x2x6. Try the following
% initialize your array of coordinates
coords = zeros(30,2,numFiles);
for k=1:numFiles
figure;
imshow(mydata{k});
[x, y] = ginput(30)
coords(:,:,k) = [x y];
end
Try the above and see what happens!