1
0

set_alpha.m 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. %%
  2. clf
  3. % z = peaks;
  4. CT = Geometry.rhomw(:,:,40);
  5. z = optResults.dose{end}(:,:,40);
  6. image(imagescX(CT, gray(256)));
  7. % imagesc(z);
  8. hold on
  9. axis image
  10. axis off
  11. %%
  12. [c, h] = contourf(z, 30:10:100, 'LineColor', 'auto');
  13. % Find all the child objects that have the FaceAlpha property
  14. alphable = findobj(h, 'Type', 'patch', '-property', 'FaceAlpha');
  15. set(alphable, 'FaceAlpha', 0.1);
  16. for i = 1:numel(alphable)
  17. % set(alphable(i), 'FaceVertexAlphaData', get(alphable(i), 'FaceVertexCData'));
  18. patch_value = get(alphable(i), 'CData');
  19. patch_value = patch_value(1);
  20. if patch_value <= 30
  21. % set(alphable(i), 'FaceAlpha', 0);
  22. end
  23. end
  24. %%
  25. p = peaks(100);
  26. subplot(1,2,1);
  27. h = imagesc(p); colorbar;
  28. levels = [-6 -2 1 8];
  29. cmap = [0 0 1;
  30. 0 1 0;
  31. 1 0 0];
  32. pimg = p;
  33. for i = 1:numel(level)-1
  34. pimg(p>=level(i) & p<level(i+1)) = i;
  35. end
  36. subplot(1,2,2);
  37. imagesc(pimg, 'CData', pimg, 'CDataMapping', 'direct');
  38. colorbar;
  39. % caxis([level(1) level(end)]);
  40. colormap(cmap);
  41. % colormap(jet(8));
  42. % set(h, 'CDataMapping', 'direct');
  43. %% caxis
  44. index = fix((C-cmin)/(cmax-cmin)*m)+1;
  45. %Clamp values outside the range [1 m]
  46. index(index<1) = 1;
  47. index(index>m) = m;