What command in python sample[i].at<uchar>(x,y)?

asked 2014-08-06 13:49:58 -0500

Shiloh gravatar image

updated 2014-08-06 13:57:32 -0500

I want to store each pixel from image(x,y) to variable samples[i] to make model

for x in range(0,width,1):
   for y in range(0,height,1):
      for i in range(0,NUMBER_SAMPLES,1):
         random=numpy.random.randint(0,9)

         row=x+cy[random]
         if(row<0):
             row=0
         if(row>=width):
             row=width-1

         col=y+cx[random]
         if(col<0):
             col=0
         if(col>=height):
             col=height-1

         " "=getPixel(cap,row,col)

The " " is jagged array (array in array) where I want to save each pixel, from here:

    sample=[]
    height, width, depth=cap.shape
    c_black=np.zeros( (height,width), dtype=np.uint8)
    for i in range(0,NUMBER_SAMPLES,1):
        sample.append(c_black)

I know in c there's command like sample[i].at<uchar>(x,y), what in python?

edit retag flag offensive close merge delete