def lightSphere(L, h=256, w=256): L = normalizeVector(L) N_32F, A_32F = normalSphere(h, w) I_32F = diffuse(N_32F, L) I_32F = I_32F * A_32F return I_32F
def _runImp(self): if self._N0_32F is None: self._computeInitialNormal() self._optimize() L = self._L self._I_32F = diffuse(self._N_32F, L) reflectance = LambertReflectanceEstimation(self._C0_32F, self._I_32F) self._C_32F = reflectance.shading(self._I_32F)
def lightSphereWithBG(L, h=256, w=256, bg_color=np.array([1.0, 0.0, 0.0])): L = normalizeVector(L) N_32F, A_32F = normalSphere(h, w) I_32F = diffuse(N_32F, L) C_32F = np.zeros(N_32F.shape) C_32F[:, :] = bg_color for ci in xrange(3): C_32F[:, :, ci] = I_32F * A_32F + (1.0 - A_32F) * C_32F[:, :, ci] return np.clip(C_32F, 0.0, 1.0)
def _runImp(self): normal_data = loadNormal(self._data_file) if normal_data is None: return N_32F, A_8U = normal_data N_32F = trim(N_32F, A_8U) A_8U = trim(A_8U, A_8U) A_32F = to32F(A_8U) L = normalizeVector(np.array([-0.2, 0.3, 0.7])) I_half = half_lambert.diffuse(N_32F, L) I_half = setAlpha(gray2rgb(I_half), A_32F) I_lambert = lambert.diffuse(N_32F, L) I_lambert = setAlpha(gray2rgb(I_lambert), A_32F) fig, axes = plt.subplots(figsize=(11, 5)) font_size = 15 fig.subplots_adjust(left=0.05, right=0.95, top=0.9, hspace=0.05, wspace=0.05) fig.suptitle("Depth From Normal", fontsize=font_size) plt.subplot(1, 4, 1) plt.title(r'Normal: $N$') plt.imshow(normalToColor(N_32F, A_8U)) plt.axis('off') plt.subplot(1, 4, 2) plt.title(r'Half Lambert: $I_h$') plt.imshow(I_half) plt.axis('off') plt.subplot(1, 4, 3) plt.title(r'Lambert: $I_l$') plt.imshow(I_lambert) plt.axis('off') showMaximize()