example.m 766 B

123456789101112131415161718192021222324252627282930
  1. [V,F] = load_mesh('../shared/cheburashka.obj');
  2. N = per_vertex_normals(V,F);
  3. S = ambient_occlusion(V,F,V,N,1000);
  4. L = cotmatrix(V,F);
  5. M = massmatrix(V,F,'voronoi');
  6. [EV,~] = eigs(-L,M,15,'sm');
  7. Z = EV(:,7);
  8. qZ = round(255*(Z - min(Z))/(max(Z)-min(Z)));
  9. C = ind2rgb(qZ,jet(256));
  10. nsp = 3;
  11. fs = 20;
  12. subplot(nsp,1,1);
  13. set(tsurf(F,V),'CData',Z,'EdgeColor','none',fphong);
  14. title('Pseudo-color ','FontSize',fs);
  15. axis equal;
  16. view(2);
  17. colormap(jet(256));
  18. subplot(nsp,1,2);
  19. set(tsurf(F,V),'CData',permute(1-[S S S],[1 3 2]),'EdgeColor','none',fphong);
  20. title('Inverted ambient occlusion ','FontSize',fs);
  21. axis equal;
  22. view(2);
  23. subplot(nsp,1,3);
  24. set(tsurf(F,V),'CData',bsxfun(@times,1-S,C),'EdgeColor','none',fphong);
  25. title('Product ','FontSize',fs);
  26. axis equal;
  27. view(2);