Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Filtering values of an array using pixel positions from an image

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 temperature values that corresponds to the ROI in the image

>Solution :

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

x, y, w, h = cv2.selectROI(my_frame)
roi = my_frame[y:+h, x:x+w]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading