summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2015-05-15 18:18:59 +0800
committerJoe Zhao <ztuowen@gmail.com>2015-05-15 18:18:59 +0800
commit81d9c2360fd88422fcf7c8bd176f0ae07af2a9bf (patch)
treebae7b6f5ded34e5d9e5244b3e51861620c9b64a4
parentc02789c3194059233b275a2de76c33f5456f0a11 (diff)
downloadfeatext-81d9c2360fd88422fcf7c8bd176f0ae07af2a9bf.tar.gz
featext-81d9c2360fd88422fcf7c8bd176f0ae07af2a9bf.tar.bz2
featext-81d9c2360fd88422fcf7c8bd176f0ae07af2a9bf.zip
updated range
-rw-r--r--510_0.bmpbin0 -> 18488 bytes
-rw-r--r--genFeatureVec.m22
-rw-r--r--getFeatureExt.m63
-rw-r--r--getSection.m7
-rw-r--r--getVecs.m4
-rw-r--r--getVecsM.m24
-rw-r--r--lena.jpgbin0 -> 60817 bytes
-rw-r--r--parGetVecs.m15
8 files changed, 118 insertions, 17 deletions
diff --git a/510_0.bmp b/510_0.bmp
new file mode 100644
index 0000000..20c1646
--- /dev/null
+++ b/510_0.bmp
Binary files differ
diff --git a/genFeatureVec.m b/genFeatureVec.m
index 7690f25..0b227fa 100644
--- a/genFeatureVec.m
+++ b/genFeatureVec.m
@@ -1,4 +1,4 @@
-function vec = genFeatureVec(img)
+function vec = genFeatureVec(img,minc,maxc)
bins = 16;
ncnls = 8;
secs = 6;
@@ -8,7 +8,7 @@ function vec = genFeatureVec(img)
hsv = rgb2hsv(img);
cnls(:,:,7:8) = hsv(:,:,1:2);
for i=1:ncnls
- cnls(:,:,i) = imgeq(cnls(:,:,i));
+ cnls(:,:,i) = histeq(cnls(:,:,i));
end
% Schmid
scVec=[
@@ -37,12 +37,14 @@ function vec = genFeatureVec(img)
gb = length(gbVec);
sc = length(scVec);
vec=[];
+ nn=1;
for i = 1:sc
for cnl = 1:ncnls
for sec = 1:secs
filt = schmidFilter(scVec(i,1),scVec(i,2));
- pos = sum(sum(filt.*(filt>0)));
- neg = sum(sum(filt.*(filt<0)));
+ pos = maxc(nn);
+ neg = minc(nn);
+ nn=nn+1;
ss = (pos-neg)/bins;
section = getSection(cnls(:,:,cnl),sec,secs);
v = histcounts(imfilter(section, filt, 'symmetric'),(0:bins)*ss+neg);
@@ -54,8 +56,9 @@ function vec = genFeatureVec(img)
for cnl = 1:ncnls
for sec = 1:secs
filt = gaborFilter(gbVec(i,1),gbVec(i,2),gbVec(i,3),gbVec(i,4));
- pos = sum(sum(filt.*(filt>0)));
- neg = sum(sum(filt.*(filt<0)));
+ pos = maxc(nn);
+ neg = minc(nn);
+ nn=nn+1;
ss = (pos-neg)/bins;
section = getSection(cnls(:,:,cnl),sec,secs);
v = histcounts(imfilter(section, filt, 'symmetric'),(0:bins)*ss+neg);
@@ -65,10 +68,3 @@ function vec = genFeatureVec(img)
end
end
-function [sec] = getSection(inp,a,b)
- [m,n] = size(inp);
- ste = (m-1)/b;
- st=1+ceil(ste*(a-1));
- ed=1+floor(ste*a);
- sec = inp(st:ed,:);
-end \ No newline at end of file
diff --git a/getFeatureExt.m b/getFeatureExt.m
new file mode 100644
index 0000000..791a7aa
--- /dev/null
+++ b/getFeatureExt.m
@@ -0,0 +1,63 @@
+function [ minc,maxc ] = getFeatureExt( img )
+ ncnls = 8;
+ secs = 6;
+ cnls = zeros(size(img,1), size(img,2),ncnls);
+ cnls(:,:,1:3) = img;
+ cnls(:,:,4:6) = rgb2ycbcr(img);
+ hsv = rgb2hsv(img);
+ cnls(:,:,7:8) = hsv(:,:,1:2);
+ for i=1:ncnls
+ cnls(:,:,i) = histeq(cnls(:,:,i));
+ end
+ % Schmid
+ scVec=[
+ 1,2;
+ 1,4;
+ 2,4;
+ 1,6;
+ 2,6;
+ 3,6;
+ 1,8;
+ 2,8;
+ 3,8;
+ 1,10;
+ 2,10;
+ 3,10;
+ 4,10];
+ gbVec = [
+ 0.3,0,4,2;
+ 0.3,0,8,2;
+ 0.4,0,4,1;
+ 0.4,0,8,2;
+ 0.3,pi/2,4,2;
+ 0.3,pi/2,8,2;
+ 0.4,pi/2,4,1;
+ 0.4,pi/2,8,2;];
+ gb = length(gbVec);
+ sc = length(scVec);
+ minc = [];
+ maxc = [];
+ for i = 1:sc
+ for cnl = 1:ncnls
+ for sec = 1:secs
+ filt = schmidFilter(scVec(i,1),scVec(i,2));
+ section = getSection(cnls(:,:,cnl),sec,secs);
+ res = imfilter(section, filt, 'symmetric');
+ minc = cat(2,minc,min(min(res)));
+ maxc = cat(2,maxc,max(max(res)));
+ end
+ end
+ end
+ for i = 1:gb
+ for cnl = 1:ncnls
+ for sec = 1:secs
+ filt = gaborFilter(gbVec(i,1),gbVec(i,2),gbVec(i,3),gbVec(i,4));
+ section = getSection(cnls(:,:,cnl),sec,secs);
+ res = imfilter(section, filt, 'symmetric');
+ minc = cat(2,minc,min(min(res)));
+ maxc = cat(2,maxc,max(max(res)));
+ end
+ end
+ end
+end
+
diff --git a/getSection.m b/getSection.m
new file mode 100644
index 0000000..a5addc3
--- /dev/null
+++ b/getSection.m
@@ -0,0 +1,7 @@
+function [sec] = getSection(inp,a,b)
+ [m,n] = size(inp);
+ ste = (m-1)/b;
+ st=1+ceil(ste*(a-1));
+ ed=1+floor(ste*a);
+ sec = inp(st:ed,:);
+end \ No newline at end of file
diff --git a/getVecs.m b/getVecs.m
index 0f0a615..715e9f2 100644
--- a/getVecs.m
+++ b/getVecs.m
@@ -1,4 +1,4 @@
-function getVecs(dirname)
+function getVecs(dirname,minc,maxc)
indir = strcat(strcat('~/VIPeR/',dirname),'/');
idlist=dir(indir);
@@ -16,7 +16,7 @@ function getVecs(dirname)
n=n(1:strfind(n,'_')-1)
end
img=im2double(imread(strcat(indir,idlist(i).name)));
- I=genFeatureVec(img);
+ I=genFeatureVec(img,minc,maxc);
fprintf(fid,'%s ',n);
fprintf(fid,'%f ',I);
fprintf(fid,'\n');
diff --git a/getVecsM.m b/getVecsM.m
new file mode 100644
index 0000000..c3b17c4
--- /dev/null
+++ b/getVecsM.m
@@ -0,0 +1,24 @@
+function [minc,maxc] = getVecsM(dirname)
+ indir = strcat(strcat('~/VIPeR/',dirname),'/');
+ idlist=dir(indir);
+ minc = [];
+ maxc = [];
+
+ for i=1:length(idlist)
+ n = idlist(i).name;
+ switch n
+ case '.'
+ continue;
+ case '..'
+ continue;
+ otherwise
+ n=n(1:strfind(n,'_')-1)
+ end
+ img=im2double(imread(strcat(indir,idlist(i).name)));
+ [mic,mac]=getFeatureExt(img);
+ minc=cat(1,minc,mic);
+ maxc=cat(1,maxc,mac);
+ end
+ minc=min(minc);
+ maxc=max(maxc);
+end \ No newline at end of file
diff --git a/lena.jpg b/lena.jpg
new file mode 100644
index 0000000..53b46db
--- /dev/null
+++ b/lena.jpg
Binary files differ
diff --git a/parGetVecs.m b/parGetVecs.m
index 53a2cce..f903494 100644
--- a/parGetVecs.m
+++ b/parGetVecs.m
@@ -1,9 +1,20 @@
function parGetVecs(dirname)
+ minc = zeros(2,1008);
+ maxc = zeros(2,1008);
parfor i=1:2
if i==1
- getVecs(strcat(dirname,'_a'));
+ [minc(i,:),maxc(i,:) ] = getVecsM(strcat(dirname,'_a'));
else
- getVecs(strcat(dirname,'_b'));
+ [minc(i,:),maxc(i,:) ] = getVecsM(strcat(dirname,'_b'));
+ end
+ end
+ minc=min(minc)
+ maxc=max(maxc)
+ parfor i=1:2
+ if i==1
+ getVecs(strcat(dirname,'_a'),minc,maxc);
+ else
+ getVecs(strcat(dirname,'_b'),minc,maxc);
end
end
end \ No newline at end of file