Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- beginT = cputime;
- %---------------------------------------------------------
- % Copyright (c) 2009 Radhakrishna Achanta [EPFL]
- % Contact: firstname.lastname@epfl.ch
- %---------------------------------------------------------
- % Citation:
- % @InProceedings{LCAV-CONF-2009-012,
- % author = {Achanta, Radhakrishna and Hemami, Sheila and Estrada,
- % Francisco and S�sstrunk, Sabine},
- % booktitle = {{IEEE} {I}nternational {C}onference on {C}omputer
- % {V}ision and {P}attern {R}ecognition},
- % year = 2009
- % }
- %---------------------------------------------------------
- % Please note that the saliency maps generated using this
- % code may be slightly different from those of the paper.
- % This seems to be because the RGB to Lab conversion is
- % different from the one used for the results in the C++ code.
- % The C++ code is available on the same page as this matlab
- % code (http://ivrg.epfl.ch/supplementary_material/RK_CVPR09/index.html)
- % One should preferably use the C++ as reference and use
- % this matlab implementation mostly as proof of concept
- % demo code.
- %---------------------------------------------------------
- % Read image and blur it with a 3x3 or 5x5 Gaussian filter
- %---------------------------------------------------------
- img = imread('../dog.jpg');%Provide input image path
- gfrgb = imfilter(img, fspecial('gaussian', 3, 3), 'symmetric', 'conv');
- %---------------------------------------------------------
- % Perform sRGB to CIE Lab color space conversion (using D65)
- %---------------------------------------------------------
- %cform = makecform('srgb2lab', 'AdaptedWhitePoint', whitepoint('d65'));
- %lab = applycform(gfrgb,cform);
- R = gfrgb(:,:,1);
- G = gfrgb(:,:,2);
- B = gfrgb(:,:,3);
- %lab = gfrgb;
- %lab = RGB2Lab(R,G,B);
- %---------------------------------------------------------
- % Compute Lab average values (note that in the paper this
- % average is found from the unblurred original image, but
- % the results are quite similar)
- %MEAN Average or mean value.
- % S = MEAN(X) is the mean value of the elements in X
- % if X is a vector. For matrices, S is a row
- % vector containing the mean value of each column.
- % For N-D arrays, S is the mean value of the
- % elements along the first array dimension whose size
- % does not equal 1.
- % If X is floating point, that is double or single,
- % S has the same class as X. If X is of integer
- % class, S has class double.
- %---------------------------------------------------------
- %l = double(lab(:,:,1)); lm = mean(mean(l));
- %a = double(lab(:,:,2)); am = mean(mean(a));
- %b = double(lab(:,:,3)); bm = mean(mean(b));
- gm = mean(mean(G));
- %---------------------------------------------------------
- % Finally compute the saliency map and display it.
- % Euclidean Distance
- %---------------------------------------------------------
- sm = 1-(G-gm);
- %sm = (l-lm).^2 + (a-am).^2 + (b-bm).^2;
- imshow(sm,[]);
- %---------------------------------------------------------
- endT = cputime - beginT;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement