MATLAB Answers


Need Help Regarding Log-Map of Images

Dear Every one!

I have to simulate image log-polar Mapping, I also have seen some sample programs on file exchange .also the logsample

If i go for coordinate conversions using the Transform expressions(formula) i get the theta and r. But I cant figure out how to plot the value at f(x,y) at (r,Theta) coordinates as they are in floating type .

if i go the reverse way from polar to Cartesian when i convert back i still don't get Real Numbers

Please help me out i have to take this simulation to FPGA ,Working in RAW (using lesser Matlab function) is required

  1 Comment

polar plots require that the radius start from 0 at the center of the plot, but log of the radius would be log of 0 which would be -infinity. log polar therefore requires infinite plots, which is seldom practical.

Log in to comment.

2 Answers

Answer by Alex Taylor on 2 Jul 2013
Edited by Alex Taylor on 2 Jul 2013
 Accepted Answer

The following link is a good starting point for an example of a log-polar image resampler in MATLAB. You appear to have already come across it.

It uses the rings/wedges rule to ensure that neighboring pixels are consistently spaced as you move out radially. As you point out, the function forces you to choose a non-zero minimum radius from the center where you will begin sampling. This is practically necessary when defining a log-polar resampler to avoid log(r) from tending toward -Inf.

I don't understand the problem you are describing with plotting floating point numbers. The default datatype in MATLAB is double precision floating point, and the MATLAB plot function is very happy to accept doubles. Are you trying to do something like this?

a  = imread('example.tif');
a  = rgb2gray(a);
xc = 0.5 + size(a,2)/2;
yc = 0.5 + size(a,1)/2;
nr = min(size(a,2),size(a,1));
rmin = 0.1;
rmax = min(xc,yc);
nw = -2*pi*(nr-1) / log(rmin/rmax);
rmin = 0.1;
rmax = min([xc-0.5,yc-0.5]);
logRho = linspace(log(rmin),log(rmax),nr);
rho = exp(logRho);
deltaTheta = 2*pi / nw;
theta = linspace(0,2*pi-deltaTheta,nw);
[rho,theta] = meshgrid(rho,theta);
[X,Y] = pol2cart(theta,rho);
X = X+xc;
Y = Y+yc;
figure, imagesc(a); colormap gray; hold on
logPolarImage = interp2(double(a),X,Y);
figure, imagesc(logPolarImage); colormap gray


Log in to comment.

Answer by Abdullah Khan on 3 Jul 2013

Dear Alex ! Thank you for the help i have checked that code and its working good.

Mean while i also wrote a code , this code isnt generalised yet , is this log map correct too ?

--------------------------- if true clear %close all clc

img=imread('cameraman.tif'); img=imrotate(img,-90); [r c]=size(img);

center_x=r/2; center_y=c/2;

size_lmap_r=128; size_lmap_t=360;


for i=1:size_lmap_r for j=1:size_lmap_t

        if j<=90 && j >= 0
        if j<=180 && j >90
        if j<=270 && j >180
        if j<=360 && j >270


i have also attached results for a non rotaed and -90 degree rotated picture

Your help is highly appreciated

Regards <>


Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Win prizes and improve your MATLAB skills

Play today