python - Image processing: Trying to make a photo negative? -


i understand make image negative, have change rgb values current value being subtracted 255.

what wrong following code?

def negative(im): height=len(im) width = len(im[0]) row in range(height):     col in range(width):         red = im[row][col][0] - 255         green = im[row][col][1] - 255         blue = im[row][col][2] - 255         im[row][col]=[red,green,blue] return im 

it returns error "tclerror: can't parse color "#-1d-c-2""

your problem getting negative numbers. think should doing 255 - x rather x - 255


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -