0

template
target

i want to check if target has the same array of template has.

for example,

#The array of template
[[[162 181   0]
  [ 36  28 237]
  [  0   0   0]
  [100  60  52]
  [ 39 127 255]]

 [[162 181   0]
  [ 36  28 237]
  [  0   0   0]
  [100  60  52]
  [ 39 127 255]]

 [[162 181   0]
  [ 36  28 237]
  [  0   0   0]
  [100  60  52]
  [ 39 127 255]]]

#the array of target
[[[162 181   0]]

 [[162 181   0]]

 [[162 181   0]]]

so if target has the same array returns true

but if target has different value like below

[[[150 181 0]]

[[162 181  0]]

[[162 181  0]]]

it returns False. how would i be able to do so?

thinking of using numpy but i dont know how

5
  • 1
    Your attached pictures are too small for me to see. Commented Dec 14, 2022 at 5:37
  • np.allclose(template[..., 0], target)? Commented Dec 14, 2022 at 5:45
  • 1
    @吴慈霆 i attached the array of template and target images Commented Dec 14, 2022 at 5:55
  • 1
    @mozway i get ValueError: operands could not be broadcast together with shapes (3,5) (3,1,3) Commented Dec 14, 2022 at 5:55
  • 1
    The template and the target array have different shapes. How do you want to perform the check in that case? Please provide an example. Commented Dec 14, 2022 at 6:02

1 Answer 1

1
any(((template[:, i, :] == target).all() for i in range(template.shape[1])))

Maybe there is a more elegant way.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.