Compare rgb values of a pixel
Posted: 2016-04-05T16:46:16-07:00
Hi,
this is a total beginner question, I know, but I'm banging my head against the wall and can't find a solution nowhere in the web.
I use wand with python and I grayscale my picture. Then after that I want to go over the picture check see if it's too light and if so make it darker. So I thought of just going over (after greyscaling) and checking if there is a pixel with the RGB value (145,145,145) and since this is too light I'll just stretch the contrast.
Therefore I have the following pseudo code:
so with the two for loops I go over every column in the image, however, I don't know how to compare the RGB values. What I get from is .
Anyone an idea how I could achieve this?
this is a total beginner question, I know, but I'm banging my head against the wall and can't find a solution nowhere in the web.
I use wand with python and I grayscale my picture. Then after that I want to go over the picture check see if it's too light and if so make it darker. So I thought of just going over (after greyscaling) and checking if there is a pixel with the RGB value (145,145,145) and since this is too light I'll just stretch the contrast.
Therefore I have the following pseudo code:
Code: Select all
with wand.image.Image (filename="myfile.png") as img:
img.type='grayscalematte';
img.save(filename="myfile.png")
with Color('#919191') as too_light:
for row in img:
for col in row:
if (???):
img.contrast_stretch(black_point=0.0)
img.save(filename="myfile.png")
return 1
Code: Select all
col
Code: Select all
srgb(0,0,0,0)
Anyone an idea how I could achieve this?