function k2 = CenPtran( k,m,n) %UNTITLED Summary of this function goes here % Detailed explanation goes here centerGPos = cenP(k); centerGPos1 = [floor(m/2)+1,floor(n/2)+1]; if mod(abs(centerGPos(1)-centerGPos1(1)),2) == 0 && mod(abs(centerGPos(2)-centerGPos1(2)),2) ==0 k1 = zeros(m+abs(centerGPos(1)-centerGPos1(1)),n+abs(centerGPos(2)-centerGPos1(2))); elseif mod((centerGPos(1)-centerGPos1(1)),2) == 0&&mod(abs(centerGPos(2)-centerGPos1(2)),2) ~=0 k1 = zeros(m+abs(centerGPos(1)-centerGPos1(1)),n+abs(centerGPos(2)-centerGPos1(2))+1); elseif mod((centerGPos(2)-centerGPos1(2)),2) ==0&&mod((centerGPos(1)-centerGPos1(1)),2) ~= 0 k1 = zeros(m+abs(centerGPos(1)-centerGPos1(1))+1,n+abs(centerGPos(2)-centerGPos1(2))); else k1 = zeros(m+abs(centerGPos(1)-centerGPos1(1))+1,n+abs(centerGPos(2)-centerGPos1(2))+1); end [k1m k1n] = size(k1); if centerGPos(1)-centerGPos1(1)>= 0 && centerGPos(2)-centerGPos1(2)>=0 for ki =1:m for kj =1:n k1(ki,kj) = k(ki,kj); end end elseif centerGPos(1)-centerGPos1(1)<0 && centerGPos(2)-centerGPos1(2)==0 for ki = (abs(centerGPos(1)-centerGPos1(1))+1):(abs(centerGPos(1)-centerGPos1(1))+m) for kj =1:k1n k1(ki,kj) = k(ki-abs(centerGPos(1)-centerGPos1(1)),kj); end end elseif centerGPos(2)-centerGPos1(2)<0&¢erGPos(1)-centerGPos1(1)== 0 for ki = 1:k1m for kj =( (abs(centerGPos(2)-centerGPos1(2)))+1):((abs(centerGPos(2)-centerGPos1(2)))+n) k1(ki,kj) = k(ki,kj-abs(centerGPos(2)-centerGPos1(2))); end end elseif centerGPos(1)-centerGPos1(1)<0&& centerGPos(2)-centerGPos1(2)>0 for ki = (abs(centerGPos(1)-centerGPos1(1))+1):(abs(centerGPos(1)-centerGPos1(1))+m) for kj =1:n k1(ki,kj) = k(ki-abs(centerGPos(1)-centerGPos1(1)),kj); end end elseif centerGPos(1)-centerGPos1(1)>0&& centerGPos(2)-centerGPos1(2)<0 for ki =1:m for kj =( (abs(centerGPos(2)-centerGPos1(2)))+1):((abs(centerGPos(2)-centerGPos1(2)))+n) k1(ki,kj) = k(ki,kj-abs(centerGPos(2)-centerGPos1(2))); end end else for ki = (abs(centerGPos(1)-centerGPos1(1))+1):(abs(centerGPos(1)-centerGPos1(1))+m) for kj =( (abs(centerGPos(2)-centerGPos1(2)))+1):((abs(centerGPos(2)-centerGPos1(2)))+n) k1(ki,kj) = k(ki-abs(centerGPos(1)-centerGPos1(1)),kj-abs(centerGPos(2)-centerGPos1(2))); end end end centerGPos2 = cenP(k1); x1 = centerGPos2(1)-floor(m/2); x2 = x1+2*floor(m/2); y1 = centerGPos2(2)-floor(n/2); y2 = y1+2*floor(n/2); k2 = k1(x1:x2,y1:y2);