hdrvdp_pix_per_deg.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. function ppd = hdrvdp_pix_per_deg( display_diagonal_in, resolution, viewing_distance )
  2. % HDRVDP_PIX_PER_DEG - computer pixels per degree given display parameters
  3. % and viewing distance
  4. %
  5. % ppd = hdrvdp_pix_per_deg( display_diagonal_in, resolution,
  6. % viewing_distance )
  7. %
  8. % This is a convenience function that can be used to provide angular
  9. % resolution of input images for the HDR-VDP-2.
  10. %
  11. % display_diagonal_in - diagonal display size in inches, e.g. 19, 14
  12. % resolution - display resolution in pixels as a vector, e.g. [1024 768]
  13. % viewing_distance - viewing distance in meters, e.g. 0.5
  14. %
  15. % Note that the function assumes 'square' pixels, so that the aspect ratio
  16. % is resolution(1):resolution(2).
  17. %
  18. % EXAMPLE:
  19. % ppd = hdrvdp_pix_per_deg( 24, [1920 1200], 0.5 );
  20. %
  21. % Copyright (c) 2011, Rafal Mantiuk <mantiuk@gmail.com>
  22. % Permission to use, copy, modify, and/or distribute this software for any
  23. % purpose with or without fee is hereby granted, provided that the above
  24. % copyright notice and this permission notice appear in all copies.
  25. %
  26. % THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  27. % WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  28. % MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  29. % ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  30. % WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  31. % ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  32. % OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  33. ar = resolution(1)/resolution(2);
  34. height_mm = sqrt( (display_diagonal_in*25.4)^2 / (1+ar^2) );
  35. height_deg = 2 * atand( 0.5*height_mm/(viewing_distance*1000) );
  36. ppd = resolution(2)/height_deg;
  37. end