def _runImp(self): image = self._scene.image() D_32F = self._scene.depth() if D_32F is None: return N_32F = depthToNormal(D_32F) self._scene.setNormal(N_32F)
def _runImp(self): # file_path = self._data_file file_path = self.resultFile(self._data_file_name, result_name="Wu08") normal_data = loadNormal(file_path) if normal_data is None: return N0_32F, A_8U = normal_data D_32F = depthFromNormal(N0_32F, A_8U) 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'Initial Normal: $N_0$') plt.imshow(normalToColor(N0_32F, A_8U)) plt.axis('off') plt.subplot(1, 4, 2) plt.title(r'Estimated Depth: $D$') plt.gray() plt.imshow(D_32F) plt.axis('off') N_32F = depthToNormal(D_32F) plt.subplot(1, 4, 3) plt.title(r'Recovered Normal: $N$') plt.imshow(normalToColor(N_32F, A_8U)) plt.axis('off') h, w = N_32F.shape[:2] N_diff = angleErros(N_32F.reshape(-1, 3), N0_32F.reshape(-1, 3)).reshape(h, w) N_diff[A_8U < np.max(A_8U)] = 0.0 plt.subplot(1, 4, 4) plt.title(r'Angle Error: $N, N_0$') plt.imshow(N_diff, cmap=plt.cm.jet, vmin=0, vmax=30.0) plt.axis('off') plt.colorbar() #out_file_path = self.resultFile(self._data_file_name) out_file_path = self.resultFile(self._data_file_name, result_name="Wu08Depth") plt.savefig(out_file_path)
def _runImp(self): normal_data = loadNormal(self._data_file) if normal_data is None: return N0_32F, A_8U = normal_data A_32F = to32F(A_8U) L = normalizeVector(np.array([-0.2, 0.3, 0.7])) #C0_32F = ToonShader().diffuseShading(L, N0_32F) C0_32F = LambertShader().diffuseShading(L, N0_32F) I0_32F = luminance(C0_32F) I0_low_32F = cv2.resize(I0_32F, (256, 256)) A_low_8U = cv2.resize(A_8U, I0_low_32F.shape) D_32F = depthFromGradient(I0_low_32F, A_low_8U) D_32F = cv2.resize(D_32F, I0_32F.shape) N_32F = depthToNormal(D_32F) self._view.setRGBAD(setAlpha(C0_32F, A_32F), D_32F)