Advertisement
Guest User

Modified Frequency-tuned Saliency

a guest
Jul 30th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.00 KB | None | 0 0
  1. beginT = cputime;
  2. %---------------------------------------------------------
  3. % Copyright (c) 2009 Radhakrishna Achanta [EPFL]
  4. % Contact: firstname.lastname@epfl.ch
  5. %---------------------------------------------------------
  6. % Citation:
  7. % @InProceedings{LCAV-CONF-2009-012,
  8. %    author      = {Achanta, Radhakrishna and Hemami, Sheila and Estrada,
  9. %                  Francisco and S�sstrunk, Sabine},
  10. %    booktitle   = {{IEEE} {I}nternational {C}onference on {C}omputer
  11. %                  {V}ision and {P}attern {R}ecognition},
  12. %    year        = 2009
  13. % }
  14. %---------------------------------------------------------
  15. % Please note that the saliency maps generated using this
  16. % code may be slightly different from those of the paper.
  17. % This seems to be because the RGB to Lab conversion is
  18. % different from the one used for the results in the C++ code.
  19. % The C++ code is available on the same page as this matlab
  20. % code (http://ivrg.epfl.ch/supplementary_material/RK_CVPR09/index.html)
  21. % One should preferably use the C++ as reference and use
  22. % this matlab implementation mostly as proof of concept
  23. % demo code.
  24. %---------------------------------------------------------
  25. % Read image and blur it with a 3x3 or 5x5 Gaussian filter
  26. %---------------------------------------------------------
  27. img = imread('../dog.jpg');%Provide input image path
  28. gfrgb = imfilter(img, fspecial('gaussian', 3, 3), 'symmetric', 'conv');
  29. %---------------------------------------------------------
  30. % Perform sRGB to CIE Lab color space conversion (using D65)
  31. %---------------------------------------------------------
  32. %cform = makecform('srgb2lab', 'AdaptedWhitePoint', whitepoint('d65'));
  33. %lab = applycform(gfrgb,cform);
  34. R = gfrgb(:,:,1);
  35. G = gfrgb(:,:,2);
  36. B = gfrgb(:,:,3);
  37. %lab = gfrgb;
  38. %lab = RGB2Lab(R,G,B);
  39. %---------------------------------------------------------
  40. % Compute Lab average values (note that in the paper this
  41. % average is found from the unblurred original image, but
  42. % the results are quite similar)
  43.  
  44. %MEAN   Average or mean value.
  45. %   S = MEAN(X) is the mean value of the elements in X
  46. %   if X is a vector. For matrices, S is a row
  47. %   vector containing the mean value of each column.
  48. %   For N-D arrays, S is the mean value of the
  49. %   elements along the first array dimension whose size
  50. %   does not equal 1.
  51. %   If X is floating point, that is double or single,
  52. %   S has the same class as X. If X is of integer
  53. %   class, S has class double.
  54.  
  55. %---------------------------------------------------------
  56. %l = double(lab(:,:,1)); lm = mean(mean(l));
  57. %a = double(lab(:,:,2)); am = mean(mean(a));
  58. %b = double(lab(:,:,3)); bm = mean(mean(b));
  59. gm = mean(mean(G));
  60. %---------------------------------------------------------
  61. % Finally compute the saliency map and display it.
  62.  
  63. % Euclidean Distance
  64. %---------------------------------------------------------
  65. sm = 1-(G-gm);
  66. %sm = (l-lm).^2 + (a-am).^2 + (b-bm).^2;
  67. imshow(sm,[]);
  68. %---------------------------------------------------------
  69. endT = cputime - beginT;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement