카메라, Tv 등 각 화소들의 v-i 특성 곡선은 불균일하다
밝기는 전류 i와 비례관계이며
입력 전압에 따라 균일한 전체 밝기가 되도록 보상할 필요가 있다.
간단하게 테스트 코드로 실제 특성을 구현해보았다.
해상도 WXH = 100 X 100 의 영상에서
픽셀 화소수가 불균일한 영상
원리는 간단하다
각 화소수들의 반응성을 y = f(x)로 모델링한다
그리고 역함수를 취해주는거다
g(x)를 f(x)의 역함수라고 하면
y = g(f(x)) = x가 되도록 만들어 주는거다!!
테스트로 만든 보상전의 v : 0~ 255 중 60, 120, 180, 240일때 영상
테스트로 만든 보상후의 v : 0~ 255 중 60, 120, 180, 240일때 영상
import numpy as np import matplotlib.pyplot as plt _2pi = 1 / np.sqrt(2*np.pi) def FuncGaus( x, mu, sig): return _2pi / sig * np.exp( -0.5* ( x - mu ) * ( x - mu) /(sig*sig)) def FuncGaus2d( x, y, mux,muy, sigx,sigy): return _2pi / (sigx * sigy) * np.exp( -(( x - mux ) * ( x - mux) /\ (2*sigx*sigx) + (y -muy)*(y-muy)/(2*sigy*sigy))) W = 100 H = 100 x = np.arange(0,W) y = np.arange(0,H) xx,yy = np.meshgrid(x,y) A = FuncGaus2d( xx, yy, 20, 30, 50,50)* 500000 + 20 print('max %f , min %f' % (np.max(A[:]), np.min( A[:]) )) A = A.reshape(-1) A = A + np.random.randn(W*H) *10 + 50 plt.imshow(A.reshape(H,W)) plt.show() # A = np.random.normal(20,10,[H,W]) B = np.random.randn(W*H) * 20 + 50 v = np.arange(0,255) A = np.expand_dims(A,axis=0) B = np.expand_dims(B,axis=0) v = np.expand_dims(v,axis=0) print(A.shape, 'x',v.shape) Y =np.matmul( A.transpose() , v) Y = Y + B.transpose() Z = Y - B.transpose() print(Z.shape, A.shape) AA = A[0,:] AA = AA.repeat(255).reshape(W*H,255) print(AA.shape) Z = Z / AA print(Y.shape) for i in range(255): img1= Y[:,i].reshape(H,W) img = Z[:,i].reshape(H,W) print('--------------------------------------------') print('mean:%f, std:%f', np.mean(img1), np.std(img1)) print('mean:%f, std:%f', np.mean(img), np.std(img)) if i % 30 == 0: plt.imshow(img1,vmin=0, vmax=35000) plt.title('not_calib%d.png'%i) plt.savefig('not_calib%d.png'%i) # plt.show() plt.imshow(img, vmin=0, vmax = 255) plt.title('calib%d.png' % i) plt.savefig('calib%d.png' % i) # plt.show()