Contrast Effects

Authors

Ndèye Gagnessiry Ndiaye and Christin Seifert

License

This work is licensed under the Creative Commons Attribution 3.0 Unported License https://creativecommons.org/licenses/by/3.0/

This notebook illustrates 3 contrast effects:

  • Simultaneous Brightness Contrast
  • Chevreul Illusion
  • Contrast Crispening

Simultaneous Brightness Contrast

Simultaneous Brightness Contrast is the general effect where a gray patch placed on a dark background looks lighter than the same gray patch on a light background (foreground and background affect each other). The effect is based on lateral inhibition.

Also see the following video as an example: https://www.youtube.com/watch?v=ZYh4SxE7Xp8


In [5]:
import numpy as np
import matplotlib.pyplot as plt

The following image shows a gray square on different backgrounds. The inner square always has the same color (84% gray), and is successively shown on 0%, 50%, 100%, and 150% gray background patches. Note, how the inner squares are perceived differently (square on the right looks considerably darker than the square on the left).

Suggestion: Change the gray values of the inner and outer squares and see what happens.


In [7]:
# defining the inner square as 3x3 array with an initial gray value
inner_gray_value = 120
inner_square = np.full((3,3), inner_gray_value, np.double)

# defining the outer squares and overlaying the inner square
a = np.zeros((5,5), np.double)
a[1:4, 1:4] = inner_square

b = np.full((5,5), 50, np.double)
b[1:4, 1:4] = inner_square

c = np.full((5,5), 100, np.double)
c[1:4, 1:4] = inner_square

d = np.full((5,5), 150, np.double)
d[1:4, 1:4] = inner_square

simultaneous=np.hstack((a,b,c,d))


im=plt.imshow(simultaneous, cmap='gray',interpolation='nearest',vmin=0, vmax=255) 
#plt.rcParams["figure.figsize"] = (70,10)
plt.axis('off')
plt.colorbar(im, orientation='horizontal')
plt.show()


Chevreul Illusion

The following images visualizes the Chevreul illusion. We use a sequence of gray bands (200%, 150%, 100%, 75% and 50% gray). One band has a uniform gray value. When putting the bands next to each other, the gray values seem to be darker at the edges. This is due to lateral inhibition, a feature of our visual system that increases edge contrasts and helps us to better detect outlines of shapes.


In [8]:
e = np.full((9,5), 200, np.double)
f = np.full((9,5), 150, np.double)
g = np.full((9,5), 100, np.double)
h = np.full((9,5), 75, np.double)
i = np.full((9,5), 50, np.double)
image1= np.hstack((e,f,g,h,i))

e[:,4] = 255
f[:,4] = 255
g[:,4] = 255
h[:,4] = 255
i[:,4] = 255
image2=np.hstack((e,f,g,h,i))

plt.subplot(1,2,1)
plt.imshow(image1, cmap='gray',vmin=0, vmax=255,interpolation='nearest',aspect=4) 
plt.title('Bands')
plt.axis('off')


plt.subplot(1,2,2)
plt.imshow(image2, cmap='gray',vmin=0, vmax=255,interpolation='nearest',aspect=4) 
plt.title('Bands with white breaks')
plt.axis('off')

plt.show()


Contrast Crispening

The following images show the gray strips on a gray-scale background. Left image: All vertical gray bands are the same. Note how different parts of the vertical gray bands are enhanced (i.e., difference better perceivable) depending on the gray value of the background. In fact, differences are enhanced when the gray value in the foreground is closer to the gray value in the background. On the right, the same vertical bands are shown but without the background. In this image you can (perceptually) verify that all vertical gray bands are indeed the same.


In [9]:
strips = np.linspace( 0, 255, 10, np.double)  
strips = strips.reshape((-1, 1))
M = np.linspace( 255, 0, 10, np.double)   
n = np.ones((20, 10), np.double)

background = n[:,:]*M
background[5:15,::2] = strips

without_background = np.full((20,10), 255, np.double)
without_background[5:15,::2] = strips

plt.subplot(1,2,1)
plt.imshow(background, cmap='gray',vmin=0, vmax=255,interpolation='nearest') 
plt.tick_params(axis='both', left='off', top='off', right='off', bottom='off', labelleft='off', labeltop='off', labelright='off', labelbottom='off')


plt.subplot(1,2,2)
plt.imshow(without_background, cmap='gray',vmin=0, vmax=255,interpolation='nearest')
plt.tick_params(axis='both', left='off', top='off', right='off', bottom='off', labelleft='off', labeltop='off', labelright='off', labelbottom='off')


plt.show()



In [ ]: