find a table in onother table by 80%

hello everyone i have a table K2 50 X 50 that has 0 and 1 and a bigger table A 4864 X 3404.i want to find if table K2 is in table A(the elements of the table ) by a threshold of 80%.i have to search in the big table but how i scan all the 50 X 50 tables exists? thanks a lot

 Accepted Answer

You could do this with two calls to conv2():
A=[1 0 1];
V=[1 1 1 1 1 0 0 1 1 0 1];
small_matrix = A;
big_matrix = V;
xbig = logical(big_matrix);
xsmall = logical(small_matrix);
Xmorethan80 = (conv2(double(xbig),double(xsmall),'valid')+...
conv2(double(~xbig),double(~xsmall),'valid')) > (numel(small_matrix)*.8)
I do not get the error you are describing with the above.

14 Comments

i had the error ?? Undefined function or method 'conv2' for input arguments of type 'char'. Sorry but i dont know any good matlab code if thew answer is so obvious.
If you have your two matrices and you name them big_matrix and small_matrix and they are binary values, the above should work.
the 2 matrices are fotos that i binarized them first.i try it in onother pc and has the same error.if you find why pls let me know,thanks anyway!!
Apparently they're not numeric if you're getting that error. Why don't you post small sample matrices.
i try it with A=[1 0 1] and V=[1 1 1 1 1 0 0 1 1 0 1] but i had the same error .
When i put out the argument 'valid' and run it again i have ??? Undefined function or method 'conv2' for input arguments of type 'logical' so maybe there is the error.
there are for sure binary cause when i print the matrices has only 0 ,1 values
Try the editted version (wrap double() around everything)
No unfortunately the same error. And i was so glad when i see the quick answer!!
It works with the matrices you provided. See update.
yes it works with my real matrices too,but i can not undterstand the result.how can i see if the small matrix is in the big by 80%?Thanks for the help !!!!!
Anywhere were this a 1 means that the small matrix centered on that pixel ion the big matrix has an >=80% equality.
find(Xmorethan80)
will tell you the linear indices directly.
i see the results with the imshow but i dont know if is the correct cause i see black pixels there that o didnt expected.Furthermore if i want to see if the table exactly is on the other table, just erase the *.8?
thanks again you are really great!!
where i see white pixels is that it found the small matric to the bigger?

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!