diff options
-rw-r--r-- | genFeatureVec.m | 42 | ||||
-rwxr-xr-x | genRid.sh | 9 | ||||
-rw-r--r-- | getVecs.m | 1 | ||||
-rw-r--r-- | parGetVecs.m | 12 | ||||
-rwxr-xr-x | runMatlab.sh | 10 |
5 files changed, 55 insertions, 19 deletions
diff --git a/genFeatureVec.m b/genFeatureVec.m index 75fa0e8..4ac8ec8 100644 --- a/genFeatureVec.m +++ b/genFeatureVec.m @@ -1,6 +1,7 @@ function vec = genFeatureVec(img) bins = 16; ncnls = 8; + secs = 6; cnls = zeros(size(img,1), size(img,2),ncnls); cnls(:,:,1:3) = img; cnls(:,:,4:6) = rgb2ycbcr(img); @@ -35,21 +36,36 @@ function vec = genFeatureVec(img) vec=[]; for i = 1:sc for cnl = 1:ncnls - filt = schmidFilter(scVec(i,1),scVec(i,2)); - pos = real(sum(sum(filt.*(filt>0)))); - neg = real(sum(sum(filt.*(filt<0)))); - ss = (pos-neg)/bins; - v = histcounts(imfilter(cnls(:,:,cnl), filt, 'symmetric'),(0:bins)*ss+neg); - vec=cat(2,vec,v); + for sec = 1:secs + filt = schmidFilter(scVec(i,1),scVec(i,2)); + pos = real(sum(sum(filt.*(filt>0)))); + neg = real(sum(sum(filt.*(filt<0)))); + ss = (pos-neg)/bins; + section = getSection(cnls(:,:,cnl),sec,secs); + v = histcounts(imfilter(section, filt, 'symmetric'),(0:bins)*ss+neg); + vec=cat(2,vec,v); + end end end for i = 1:gb for cnl = 1:ncnls - filt = gaborFilter(gbVec(i,1),gbVec(i,2),gbVec(i,3),gbVec(i,4)); - pos = real(sum(sum(filt.*(filt>0)))); - neg = real(sum(sum(filt.*(filt<0)))); - ss = (pos-neg)/bins; - v = histcounts(real(imfilter(cnls(:,:,cnl), filt, 'symmetric')),(0:bins)*ss+neg); - vec=cat(2,vec,v); + for sec = 1:secs + filt = gaborFilter(gbVec(i,1),gbVec(i,2),gbVec(i,3),gbVec(i,4)); + pos = real(sum(sum(filt.*(filt>0)))); + neg = real(sum(sum(filt.*(filt<0)))); + ss = (pos-neg)/bins; + section = getSection(cnls(:,:,cnl),sec,secs); + v = histcounts(real(imfilter(section, filt, 'symmetric')),(0:bins)*ss+neg); + vec=cat(2,vec,v); + end end - end
\ No newline at end of file + 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/genRid.sh b/genRid.sh new file mode 100755 index 0000000..b2676f2 --- /dev/null +++ b/genRid.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +ofile=${1}.rid + +runMatlab parGetVecs \'${1}\' +echo 16128 > ${ofile} +cat ${1}_a.txt >> ${ofile} +cat ${1}_b.txt >> ${ofile} +echo 0 >> ${ofile} @@ -21,6 +21,5 @@ function getVecs(dirname) fprintf(fid,'%f ',I); fprintf(fid,'\n'); end - fprintf(fid,'0'); fclose(fid); end
\ No newline at end of file diff --git a/parGetVecs.m b/parGetVecs.m index 4097f5a..53a2cce 100644 --- a/parGetVecs.m +++ b/parGetVecs.m @@ -1,7 +1,9 @@ -parfor i=1:2 - if i==1 - getVecs('test_a'); - else - getVecs('test_b'); +function parGetVecs(dirname) + parfor i=1:2 + if i==1 + getVecs(strcat(dirname,'_a')); + else + getVecs(strcat(dirname,'_b')); + end end end
\ No newline at end of file diff --git a/runMatlab.sh b/runMatlab.sh new file mode 100755 index 0000000..88bb130 --- /dev/null +++ b/runMatlab.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +matlab_exec=matlab +tmpdir="/tmp" +inp="${1}(${2})" +scriptfile=${tmpdir}/matlab_command_${1}.m +echo ${inp} > ${scriptfile} +cat ${scriptfile} +${matlab_exec} -nodisplay -nosplash < ${scriptfile} +rm ${scriptfile} |