line - Finding the distance between two plot curves with unknown equations in MATLAB -


i'm working on matlab project need find distance between 2 bones of knee.

after using chenvese program active contours , manage plot curves of bones, need find space between them.

enter image description here

i tried various programs using interp1 function curves don't have same size/length. tried extract curve equations findobj didn't me anywhere.

%*********************** chen vese *********************************** m=zeros(size(ibinaire,1),size(ibinaire,2)); m(300:900,400:1200)=1; %200,1200 seg = chenvese(ibinaire,m,500,0.2,'chan');  %*********************** courbes de contours ************************* c = contour(seg); s = getcontourlines(c); plot(s(1).x,-s(1).y, 'b', s(2).x,-s(2).y,'g', s(3).x,-s(3).y,'r')  h = findobj('type', 'line', 'marker', '-and', 'b', [1 0]); xx1 = get(h, 'xdata') yy1 = get(h, 'ydata')   h = findobj('type', 'line', 'marker', '-and', 'g', [1 0]); xx2 = get(h, 'xdata') yy2 = get(h, 'ydata')  %****************distance entre lignes ************************ z1=xx1+1i*yy1; z2=xx2+1i*yy2; i=interligne(z1,z2);  plot(i) 

interligne program calculate distance between 2 curves, doesn't work , tell me curves not same size...

here's sample code how solve interp1:

% make test data s = [     struct('x',linspace(0,10,20)','y',1+(3-linspace(0,10,20)').^2);     struct('x',linspace(0,10,30)','y',-(4-linspace(0,10,30)').^2);     ];  % logic here f = @(i,p) interp1(1:numel(s(i).x), [s(i).x,s(i).y],p);  d = @(x) norm(f(1,x(1))-f(2,x(2)));  x = fminsearch(d,[5,5]) % use reasonable start point  % visualization res = [f(1,x(1));f(2,x(2))] clf line(s(1).x,s(1).y,'color','b') line(s(2).x,s(2).y,'color','g') line(res(:,1),res(:,2),'color','r','marker','x') axis([0,10,-5,5]) 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -