I am trying to pass a window over an image so I can get the average b,g,r pixel values inside the window (not really sure how to do this).
At the moment I am trying to get a window to pass over my image but on line 17 I get the error:
Traceback (most recent call last):
File "C:\Python27\bgr.py", line 17, in <module>
pt2=(pt1.x+5,pt1.y+5)
AttributeError: 'tuple' object has no attribute 'x'
Any ideas?
Here is my code:
# import packages
import numpy as np
import argparse
import cv2
import dateutil
from matplotlib import pyplot as plt
bgr_img = cv2.imread('images/0021.jpg')
height, width = bgr_img.shape[:2]
#split b,g,r channels
#b,g,r = cv2.split(bgr_img)
for i in range(0,height):
for j in range(0,width):
pt1=(i,j)
pt2=(pt1.x+5,pt1.y+5)
point.append([pt1,pt2])
cv2.rectangle(bgr_img,pt1,pt2,(255,0,0))
#cv2.imshow('image',bgr_img)
#cv2.waitKey(0)
Thanks in advance :)