0

I have a image in greyscale. I have the value of each pixel saved to a text document that I pre-processed and loaded as an array, therefore my array has size 110529.

An example of how my array looks like:

import numpy as np
my_array = np.random.randint(low=18., high=36,size=(110592))

Then, I used OpenCV to draw a ROI around the face in my image like this:

x, y, w, h = cv2.selectROI(my_frame)

and the values of x, y, w, h are:

 95 2 184 286

What I want to do is use the pixel indices in the ROI from that image as reference and use those indices to extract to a new array the values that are inside my_array, so I can have a filtered array with 52624 values that corresponds to the ROI in the image

1 Answer 1

1

what you wanted is not called "filtering" but a "numpy slice":

x, y, w, h = cv2.selectROI(my_frame)
roi = my_frame[y:y+h, x:x+w]
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.