-1

I need help with a trivial problem. I have an image in which i defined a region of interest in that image. now i want to examine the pixel values of my ROI, so that if the ROI color range e.g.between (105,105,105) and (255,255,255) then print 'left' otherwise print write.

The problem is that im unable to formulate to if statement

example code:

import cv2
import matplotlib.pyplot as pltl
import numpy as np


frame=cv2.imread('frame 8 sec.jpg')


ROI=frame[450:500,380:391]



**if the color of ROI is in range of (105,105,105) and (255,255,255):!!!???** 

cv2.putText(frame,"Status {}".format('left'), (10,20), cv2.FONT_HERSHEY_SIMPLEX,1,(0,255,0,3))
else:
cv2.putText(frame,"Status {}".format('write'), (10,20), cv2.FONT_HERSHEY_SIMPLEX,1,(0,0,255,3)) 

cv2.imshow('img',frame)
counter=counter+1


cv2.waitKey(0)
cv2.destroyAllWindows()

I would be grateful to get some help thanks in advance

Khaled
  • 555
  • 1
  • 6
  • 26

1 Answers1

0

Try this.

if (ROI>=105).all() and (ROI<=255).all():
Mercury
  • 3,417
  • 1
  • 10
  • 35