Home > SaliencyToolbox > hueDistance.m

hueDistance

PURPOSE ^

hueDistance - computes the distance in a simplified 2d color space.

SYNOPSIS ^

function result = hueDistance(col_img,hueParams)

DESCRIPTION ^

 hueDistance - computes the distance in a simplified 2d color space.

 result = hueDistance(col_img,hueParams)
    Computes the distance of each pixel of the
    RGB image col_img in a 2d color space (akin to CIE (r,g)) with 
    respect to the color model in hueParams.
    The result is a 2d array with values between 1 and 0.

    hueParams is a struct that describes a 2d Gaussian 
    color distribution in the color space with fields:
       muR - mean value in the CR direction.
       sigR - standard deviation in the CR direction.
       muG - mean value in the CG direction.
       sigG - standard deviation in the CG direction.
       rho - correlation coefficient between CR and CG.

 For details see appendix A.4 of Dirk's PhD thesis:
    Dirk Walther (2006). Interactions of visual attention and object recognition: 
    Computational modeling, algorithms, and psychophysics. Ph.D. thesis.
    California Institute of Technology. 
    http://resolver.caltech.edu/CaltechETD:etd-03072006-135433.

 or this book chapter:
    Dirk B. Walther & Christof Koch (2007). Attention in 
    Hierarchical Models of Object Recognition. In P. Cisek, 
    T. Drew & J. F. Kalaska (Eds.), Progress in Brain Research: 
    Computational Neuroscience: Theoretical insights into brain 
    function. Amsterdam: Elsevier.

 See also makeHuePyramid, skinHueParams, dataStructures.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % hueDistance - computes the distance in a simplified 2d color space.
0002 %
0003 % result = hueDistance(col_img,hueParams)
0004 %    Computes the distance of each pixel of the
0005 %    RGB image col_img in a 2d color space (akin to CIE (r,g)) with
0006 %    respect to the color model in hueParams.
0007 %    The result is a 2d array with values between 1 and 0.
0008 %
0009 %    hueParams is a struct that describes a 2d Gaussian
0010 %    color distribution in the color space with fields:
0011 %       muR - mean value in the CR direction.
0012 %       sigR - standard deviation in the CR direction.
0013 %       muG - mean value in the CG direction.
0014 %       sigG - standard deviation in the CG direction.
0015 %       rho - correlation coefficient between CR and CG.
0016 %
0017 % For details see appendix A.4 of Dirk's PhD thesis:
0018 %    Dirk Walther (2006). Interactions of visual attention and object recognition:
0019 %    Computational modeling, algorithms, and psychophysics. Ph.D. thesis.
0020 %    California Institute of Technology.
0021 %    http://resolver.caltech.edu/CaltechETD:etd-03072006-135433.
0022 %
0023 % or this book chapter:
0024 %    Dirk B. Walther & Christof Koch (2007). Attention in
0025 %    Hierarchical Models of Object Recognition. In P. Cisek,
0026 %    T. Drew & J. F. Kalaska (Eds.), Progress in Brain Research:
0027 %    Computational Neuroscience: Theoretical insights into brain
0028 %    function. Amsterdam: Elsevier.
0029 %
0030 % See also makeHuePyramid, skinHueParams, dataStructures.
0031 
0032 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2013
0033 % by Dirk B. Walther and the California Institute of Technology.
0034 % See the enclosed LICENSE.TXT document for the license agreement.
0035 % More information about this project is available at:
0036 % http://www.saliencytoolbox.net
0037 
0038 function result = hueDistance(col_img,hueParams)
0039 
0040 if ~isa(col_img,'double')
0041   col_img = im2double(col_img);
0042 end
0043 
0044 r = col_img(:,:,1);
0045 g = col_img(:,:,2);
0046 b = col_img(:,:,3);
0047 int = r + g + b;
0048 
0049 cr = safeDivide(r,int) - hueParams.muR;
0050 cg = safeDivide(g,int) - hueParams.muG;
0051 
0052 result = exp(-(cr.^2/hueParams.sigR^2/2 + ...
0053                cg.^2/hueParams.sigG^2/2 - ...
0054                cr.*cg * hueParams.rho/hueParams.sigR/hueParams.sigG));

Generated on Thu 18-Jul-2013 06:10:46 by m2html © 2005