MATLAB Answers

how to assign ID

25 views (last 30 days)
karishma koshy
karishma koshy on 30 Jul 2019
Hi
I want to find assigned point in fram k+1 the below 8x6 logical matrix (locations where its 1). I have got the below matrix after doing munkres algorithm to find the shortest distance.
matrix =[1 0 0 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 0 0 1
0 0 0 0 0 0]
then i want to check if elements of cost matrix below is less than threshold (eg:20)
3.78269075791294 278.548721531889 77.0483578413583 319.089385747004 72.3994091374370 341.243380767610
320.592670775924 502.410281024145 391.613587309557 1.70715905820170 252.111134589054 400.821864561790
71.6724364458890 291.477613257434 136.358877273355 255.879901151185 3.59902165178262 306.236057160077
317.477686638447 585.025649185487 391.175631697579 230.260817991186 292.577668505920 563.618080442638
278.854570295432 3.81058814489312 227.217240119693 503.731220780547 291.669067062947 221.356635566811
81.4885326821510 230.323795489155 5.96133868606709 397.677352526140 145.542252400360 345.981529098511
361.919791413408 292.340013620655 375.773820610502 349.149722492680 307.422993601501 82.3983010728358
181.860607286048 317.121151668522 235.113062861616 186.520583928155 107.847881217621 249.910660475223
  • if the threshold less than 20, i want to link points in k+1 frame with the same ID number of the points in frame k+1. (The above matrix is output of pdist2, so the small numbers as difference suggest that it was the same object as in frame k, ie it hasnt displaced drastically.)
  • if not, use new ID number.

  2 Comments

James Tursa
James Tursa on 30 Jul 2019
What would be the desired output for your example?
karishma koshy
karishma koshy on 30 Jul 2019
For example if I have 2 objects detected in k and 3 objects detected in k+1 frame then as follows:
ID
1
2
1
2
3

Sign in to comment.

Answers (1)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi on 5 Aug 2019
Hi Karishma!
It’s a bit unclear to me from the description how you’re getting this output. I’m assuming that you are facing an issue with manipulating the matrices.
Start with loading the values into variables. Use the relational operator to identify the indices in the cost matrix that don’t satisfy the threshold condition –
matValues = []; % Matrix values
cost= []; % Cost values
loc = cost<20; % Results in an 8x6 logical array
After this step, you may use simple if-else statements and indexing through the matrices to get your expected values.
Hope this helps!

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags