I have this data below:
data = np.array([[1, 0,-1, 0, 0, 1, 0,-1, 0, 0, 1],
[1, 1, 0, 0,-1, 0, 1, 0, 0,-1, 0],
[1, 0, 0, 1, 0, 0,-1, 0, 1, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0]])
i want to calculate how many 0
in each row and the count is for every 0
next to each other.
the result I was hoping for was new array like this:
[[1 2 1 2]
[2 1 2 1]
[2 2 1 2]
[2 5 2]]
and i want to search the 2 1 2
pattern ratio(also in every row) with some tolerance(if the number deviates slightly) and save the coordinate of 1
in the pattern.
so, I'll found 212
, or 424
, or 636
, or 9 5 10
(tolerated), etc
expected result:
[[0,6],[1,5],[2,7]]
those are the positions of every 1
in 212
pattern of data
array
I've tried with this code below:
np.unique(data, return_counts=True, axis=1)
I fiddling with that and the result was not as I expected. This is used for image processing and the data was huge