I have matrix 32x32 that is my sample and matrix of variable length that is input.
I had split sample to chunks of 4x4 numbers and need to search whole chunks in input matrix. Problem is that i don't want to compare every number in array with one position like numpy.isin does. What i need to do is mark all 4x4 occurrences in input matrix as True if all 4x4 values match with current chunk from sample. It doesn't matter how chunk is placed, only important thing is that every number in chunk will be equal in the input matrix area that we are comparing to.
Sample is 32x32 numbers every time ,but input matrix changes in size and can vary in size from 800x600 to 1920x1080
Example:
We have
Input Matrix:
1 1 2 3 7 9 4 2 9 7 9 7
2 1 4 5 1 4 7 5 4 1 4 1
0 1 0 0 3 0 1 1 0 3 0 3
8 4 2 1 9 1 2 3 1 9 1 9
4 2 4 2 7 9 7 9 7 9 4 2
7 5 7 5 1 4 1 4 1 4 7 5
1 1 1 1 3 0 3 0 3 0 1 1
2 3 2 3 9 1 9 1 9 1 2 3
Sample Matrix Chunk 1:
1 1 2 3
2 1 4 5
0 1 0 0
8 4 2 1
Sample Matrix Chunk 2:
2 3 7 9
4 5 1 4
0 0 3 0
2 1 9 1
Algorithm needs to mark all equal sub arrays to sample chunk in input matrix to True
Expected Result After comparing first chunk:
1 1 1 1 0 0 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
Expected Result After comparing second chunk:
0 0 1 1 1 1 0 0 0 0 0 0
0 0 1 1 1 1 0 0 0 0 0 0
0 0 1 1 1 1 0 0 0 0 0 0
0 0 1 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
Found chunks need to be merged into one result such as
Expected Result:
1 1 1 1 1 1 0 0 0 0 0 0
1 1 1 1 1 1 0 0 0 0 0 0
1 1 1 1 1 1 0 0 0 0 0 0
1 1 1 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
I would like to solve this in most effective way and with using as little for loops as possible.