userDS userDS - 1 year ago 109
Python Question

Find clipped pixels in a RGB image

I have an image image.png and I want to find all clipped pixels. Here is what I have so far:

for i in range(1,width):
for j in range(1, height):
r,g,b = image.getpixel((i,j))
If( ): # I don't know what should be the condition here
# do something else

I use Python, Tkinter, Pil.


Answer Source

If by 'clipped' you mean saturated, then you probably want to create a threshold based on the intensity of the pixel. There are a few equations that try to determine this, but I would recommend one of the Grayscale equations. Looking at the equation used in ATSC:


Then just figure out what range of values for I you considered 'clipped'.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download