Need Help Regarding Logmap
1 view (last 30 days)
Show older comments
Hi,
I'm trying to implement Logmap (Log-Polar Mapping)of Images..Here i don't want to use Matlab functions (built-in) have to do this simply using loops .As i have to move the algo to FPGA next.
I have Implemented using very less (almost no Matlab function except pol2cart), But the results are not smooth enough , can any one explain me hoe to improve or solve the checker board type problem even after using averaging in neighbours
Im putting the code here its a lil dirty still, also comments are removed
clc
clear
close all
a = imread('cameraman.tif');
[r c]=size(a);
ps=1; % Padding size
aa=zeros(r+10,c+10);
aa(ps+1:r+ps,ps+1:c+ps)=a;
% Claculating the center
xc = 0.5 + size(a,2)/2;
yc = 0.5 + size(a,1)/2;
% Number of Rings
nr = min(size(a,2),size(a,1));
rmin = 0.1; %Innermosr ring radai
rmax = min(xc,yc); %OuterMost ring radai
nw = (-2*pi*(nr-1)) / log(rmin/rmax); % Number of wedges with out center
rmin = 0.1;
rmax = min([xc-0.5,yc-0.5]);
deltaTheta = (2*pi) / nw;
step_r=(log(rmax)-log(rmin))/(nr-1); % Step for equal spaced items
step_t=((2*pi)-deltaTheta)/(nw-1);
lp_img=[];
lp_img_2=[];
x_d=[];
y_d=[];
x=1;
y=1;
pix=[];
for logRho=log(rmin):step_r:log(rmax)
rho = exp(logRho);
for theta=0:step_t:((2*pi)-deltaTheta)
[Y,X] = pol2cart(theta,rho);
X = (X+xc+ps);
Y = (Y+yc+ps);
X=round(X);
Y=round(Y);
% x_d(x,y)=X;
% y_d(x,y)=Y;
pix=aa(abs(X-ps):X+ps,(abs(Y-ps):Y+ps));
[rr cc]=size(pix);
av=sum(sum(pix))/(rr*cc);
lp_img(y,x)= av;
y=y+1;
end
y=1;
x=x+1;
end
figure, imagesc(lp_img); colormap gray
0 Comments
Answers (0)
See Also
Categories
Find more on Colormaps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!