Pass[9]提出了图像的颜色聚合向量(color coherence vector)。它是颜色直方图的一种演变,其核心思想是将属于直方图每一个bin的像素进行分为两部分:如果该bin内的某些像素所占据的连续区域的面积大于给定的阈值,则该区域内的像素作为聚合像素,否则作为非聚合像素。假设αi与βi分别代表直方图的第i个bin中聚合像素和非聚合像素的数量,图像的颜色聚合向量可以表达为<(α1,β1),(α2,β2),…,(αN,βN)>。而<α1+ β1,α2 + β2,αN +βN > 就是该图像的颜色直方图。由于包含了颜色分布的空间信息,颜色聚合向量相比颜色直方图可以达到更好的检索效果。
MATLAB实现:
% CCV : This is the normal Color Coherence Vector % % ICCV : This is an Improved Color Coherence Vector by adding max coherent pixels’ spatial information without affecting the performance % % Parallel implementation based on these papers : % % 1) Comparing Images Using Color Coherence Vectors (1996) - http://goo.gl/LkWkbi - % % 2) An Improved Color Coherence Vector - http://goo.gl/FjXHje - % getCCV and getICCV function take an image and return the Color Coherence Vector that describe this Image function CCV = getCCV(img,coherentPrec,numberOfColors) if ~exist('coherentPrec','var') coherentPrec = 1; end if ~exist('numberOfColors','var') numberOfColors = 27; end CCV = zeros(2,numberOfColors); Gaus = fspecial('gaussian',[5 5],2); img = imfilter(img,Gaus,'same'); [img,updNumOfPix]= discretizeColors(img,numberOfColors); imgSize = (size(img,1)*size(img,2)); thresh = int32((coherentPrec/100) *imgSize); parfor i=0:updNumOfPix-1 BW = img==i; CC = bwconncomp(BW); compsSize = cellfun(@numel,CC.PixelIdxList); incoherent = sum(compsSize(compsSize>=thresh)); CCV(:,i+1) = [incoherent; ... sum(compsSize) - incoherent]; end end function ICCV = getICCV(img,numberOfColors) if ~exist('coherentPrec','var') coherentPrec = 1; end if ~exist('numberOfColors','var') numberOfColors = 27; end ICCV = zeros(4,numberOfColors); Gaus = fspecial('gaussian',2); img = imfilter(img,'same'); [img,numberOfColors); imgSize = (size(img,2)); thresh = int32((coherentPrec/100) *imgSize); for i=0:updNumOfPix-1 BW = img==i; CC = bwconncomp(BW); compsSize = cellfun(@numel,CC.PixelIdxList); [~,idx] = max(compsSize); if isempty(idx)==0 [subI,subJ] = ind2sub(size(img),CC.PixelIdxList{idx}); meanPos = uint32(mean([subI subJ],1)); else meanPos = [0 0]; end incoherent = sum(compsSize(compsSize>=thresh)); ICCV(:,i+1) = [incoherent; ... sum(compsSize) - incoherent;meanPos']; end end function [oneChannel,updatedNumC] = discretizeColors(img,numColors) width = size(img,2); height = size(img,1); oneChannel = zeros(height,width); % We have 3 channels. For each channel we have V unique values. % So we want to find the value of V given that V x V x V ~= numColors numOfBins = floor(pow2(log2(numColors)/3)); numOfBinsSQ = numOfBins*numOfBins; img = floor((img/(256/numOfBins))); for i=1:height for j=1:width oneChannel(i,j) = img(i,j,1)*numOfBinsSQ ... + img(i,2)*numOfBins + img(i,3); end end updatedNumC = power(numOfBins,3); end分别对一张图片得到CCV和ICCV特征,然后进行后续的处理 原文链接:https://www.f2er.com/javaschema/284785.html