## I need some help with image processing

on 13 Oct 2019
Latest activity Answered by Image Analyst

### Image Analyst (view profile)

on 13 Oct 2019
Hi, I have a project at my school, in wich I need to track motion of a person’s hand. The person must draw a 2d shape before a camera. I use a marker to track the motion. To simplify the task, first, I want to process a single line, at the end it would be great to do it with a more complex shape like a pentagon. So, to process the line, I did this:
I set the images to binary, thus I can get the marker’s position.
%%
image_folder='C:\Users\Simli\Suli\Projekt\Kepek'filenames=dir(fullfile(image_folder,'*.jpg'));
total_images=numel(filenames);
ycoor=zeros(1,total_images);
xcoor=zeros(1,total_images);
%%
for n=1:total_images
f=fullfile(image_folder,filenames(n).name);
gray1=rgb2gray(kep);
imgtresh=gray1>175;
imshow(imgtresh);
s=regionprops(imgtresh,'Centroid');
xcoor(n) = round((s.Centroid(1)));
ycoor(n) = round((s.Centroid(2)));
imshow(imgtresh);
end
I would like to ask your help in the evaluating. I mean, I get 2 coordinates: x-y, but what sould I do to them to measure the drawed line straightness for example. Or am I doing it right, or is it a dead end, and never going to work?
Thanks a lot!

### Image Analyst (view profile)

on 13 Oct 2019

Maybe compute the sum of the residuals from a line
coefficients = polyfit(xcoor, ycoor, 1);
yFitted = polyval(coefficients, xcorr);
sumOfResiduals = sum(yFitted - ycoor)
Or use corrcoeff()