[Tutor] How to save each pixel from image to jagged array in exact coordinate
Whees Northbee
ch.de2.2309 at gmail.com
Wed Aug 6 21:59:16 CEST 2014
Hello, I try do background subtraction using python, and I have problem to
save each pixel to jagged array...
*My jagged array is:*
m_samples=[]
height, width, depth=cap.shape
c_black=np.zeros( (height,width), dtype=np.uint8)
for i in range(0,NUM_SAMPLES,1):
m_samples.append(c_black)
*And my code to access each pixel from frame is:*
NUM_SAMPLES =18
c_xoff= [-1, 0, 1, -1, 1, -1, 0, 1, 0]
c_yoff= [-1, 0, 1, -1, 1, -1, 0, 1, 0]
for i in range(0,width,1):
for j in range(0,height,1):
for k in range(0,NUM_SAMPLES,1):
random=numpy.random.randint(0,9)
row=i+c_yoff[random]
if(row<0):
row=0
if(row>=width):
row=width-1
col=j+c_xoff[random]
if(col<0):
col=0
if(col>=height):
col=height-1
_____________=getPixel(frame,row,col)
what I want to fill in ____ is m_samples[k] in coordinate (i,j), but I
don't know how to write it in python?
Thanks for your help...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140807/f4d5401f/attachment.html>
More information about the Tutor
mailing list