Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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(img,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?

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

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(img,row,col)
"=getPixel(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?

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

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(row,col)
"=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?