matlab - Implementation of shadow free 1d invariant image -
i implemented method removing shadows based on invariant color features found in paper entropy minimization shadow removal. implementation seems yielding similar computational results sometimes, off, , grayscale image blocky, maybe result of incorrectly taking geometric mean.
here illustration plot of info potential horse image in paper invariant image. multiply x-axis 3 theta(which goes 0 180):
and here grayscale image code outputs right maximum theta (mine off 10):
you can see blockiness image doesn't have:
here info potential:
when dividing geometric mean, have tried using nan , tresholding image smallest possible value .01, doesn't seem alter output.
here code:
i = im2double(imread(strname)); [m,n,d] = size(i); = max(i, .01); chrom = zeros(m, n, 3, 'double'); = 1:m j = 1:n % if ((i(i,j,1)*i(i,j,2)*i(i,j,3))~= 0) chrom(i,j, 1) = i(i,j,1)/((i(i,j,1)*i(i,j,2)*i(i,j, 3))^(1/3)); chrom(i,j, 2) = i(i,j,2)/((i(i,j,1)*i(i,j,2)*i(i,j, 3))^(1/3)); chrom(i,j, 3) = i(i,j,3)/((i(i,j,1)*i(i,j,2)*i(i,j, 3))^(1/3)); % else % chrom(i,j, 1) = 1; % chrom(i,j, 2) = 1; % chrom(i,j, 3) = 1; % end end end p1 = mat2gray(log(chrom(:,:,1))); p2 = mat2gray(log(chrom(:,:,2))); p3 = mat2gray(log(chrom(:,:,3))); x1 = mat2gray(p1*1/(sqrt(2)) - p2*1/(sqrt(2))); x2 = mat2gray(p1*1/(sqrt(6)) + p2*1/(sqrt(6)) - p3*2/(sqrt(6))); maxinf = 0; maxtheta = 0; data2 = zeros(1, 61); theta = 0:3:180 m = x1*cos(theta*pi/180) - x2*sin(theta*pi/180); s = sqrt(std2(x1)^(2)*cos(theta*pi/180) + std2(x2)^(2)*sin(theta*pi/180)); s = abs(1.06*s*((m*n)^(-1/5))); [m, n] = size(m); length = m*n; sources = zeros(1, length, 'double'); count = 1; x=1:m y = 1:n sources(1, count) = m(x , y); count = count + 1; end end weights = ones(1, length); sigma = 2*s; [xc , ak] = fgt_model(sources , weights , sigma , 10, sqrt(length) , 6 ); sum1 = sum(fgt_predict(sources , xc , ak , sigma , 10 )); sum1 = sum1/sqrt(2*pi*2*s*s); data2(theta/3 + 1) = sum1; if (sum1 > maxinf) maxinf = sum1; maxtheta = theta; end end invariantimage2 = cos(maxtheta*pi/180)*x1 + sin(maxtheta*pi/180)*x2;
assume fast gauss transform correct.
i don't know whether makes difference more month now, blockiness , different info potential plot caused compression of used image. can't expect getting same results using image had, because have used raw, high resolution uncompressed version of it. have impressed results, implementing info potential. thing went on head little.
john.
matlab image-processing signal-processing shadow
No comments:
Post a Comment