Here you have an impartial and simple tool to see the real intensity of an image and avoid optical illusions.
This is just a simple tool that shows the intensity of a line of the image graphically. The intensity values between the black horizontal lines are represented in the top blue graphic. Its derivative is shown below in green (press key 'g' to show it).
The derivative represents the slope of the intensity. The peaks of the derivative (local maximums and minimums) correspond to the points of maximum slope, which in the case of the image correspond to the edges. Then, to find the exact location of an edge in the image you have to look at the peaks in the green graph. Higher positive peaks correspond to transitions from black to white and negative peaks correspond to transitions from white to black.
If you don't have the Java plugin, you can watch a video of it.
With this tool you can know the real intensity of the pixels and avoid some optical illusions:
Cornsweet illusion: in this image the region at right seems lighter than the left one. If you put a finger to hide the central edge, you will see that both sides have the same intensity. With the applet you can see the real values of the intensity:
Simultaneous contrast illusion: the surrounding or background brightness affects the way we perceive the color or intensities of the objects. The central rectangle in the following example is flat, but it seems that has a gradient because the background affects the way we see it:
Same_color_illusion: This also is related to the Color_constancy, we automatically remove the shadows and illumination of the objects in such a way that the colors remain constant. In the following example, this effect makes it difficult to see that in fact the A and B squares have exactly the same value of intensity:
Most Barcode readers use the same approach as the applet above: instead of analyzing all the image, they analyze only a line each time. The process is repeated with different angles until one line crosses all the bars of the barcode and it is read correctly:
In these cases, it may be useful to filter the image with some filter (center-surround or edge detector) like the ones in the Integral Images demo, to reduce noise, enhance the features of interest or remove the global gradient of the background.
It is also possible to achieve subpixel accuracy in the location of the edges by approximating each peak of the derivative to a parabola and search for its vertex. This is useful in machine vision gauging (measuring distances accurately).