python - Accessing PIL image subelements, and taking a string from it -



python - Accessing PIL image subelements, and taking a string from it -

at moment have image sample single string out of illustration outlines details below (assume image has been loaded memory pil access)

# image size of: image[480,640] (binary image example) # take string level (y = 200) start (x = 250) sample_binary = image[x:1,y]

but when seek access throwing error asking integer (so understand it, doesn't utilize python strings possibly??), means can access 1 pixel, there anyway can sample line start of image row (x = 0 x = 250) on column (y = 200)?

thankyou time

without using numpy arrays:

from pil import image = image.open("basic_training.png") # line def get_line(i, y): pixels = i.load() # not list, nor list()'able width, height = i.size all_pixels = [] xpos in range(width): cpixel = pixels[xpos, y] all_pixels.append(cpixel) homecoming all_pixels # columns def get_column(i, x): pixels = i.load() # not list, nor list()'able width, height = i.size all_pixels = [] ypos in range(height): cpixel = pixels[x, ypos] all_pixels.append(cpixel) homecoming all_pixels line = get_line(i, y) print len(line) col = get_column(i, x) print len(col)

get_line gives line, given y position of get_col gives column given x position of

your description of string, image, etc kind of confusing. did not know if want 1 pixels, whole line, etc. code above, returns normal python list, can ','.join(col) them or way need them.

python string variables python-imaging-library

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -