Need Help Regarding Log-Map of Images

on 2 Jul 2013

Alex Taylor (view profile)

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

Walter Roberson

Walter Roberson (view profile)

on 2 Jul 2013

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.

Products

No products are associated with this question.

Alex Taylor (view profile)

on 2 Jul 2013
Edited by Alex Taylor

Alex Taylor (view profile)

on 2 Jul 2013

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.

http://www.mathworks.com/matlabcentral/fileexchange/27023-log-polar-image-sampling

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
plot(X,Y,'.');
```
```logPolarImage = interp2(double(a),X,Y);
```
```figure, imagesc(logPolarImage); colormap gray
```

Abdullah Khan (view profile)

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

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

size_lmap_r=128; size_lmap_t=360;

lp=zeros(size_lmap_r,size_lmap_t);

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

```        x=abs(round(exp(log(i))*cos(deg2rad(j))));
```        if j<=90 && j >= 0
lp(i,j)=img(-x+center_x+1,-y+center_y+1);
end```
```        if j<=180 && j >90
lp(i,j)=img(center_x+x,-y+center_y+1);
end```
```        if j<=270 && j >180
lp(i,j)=img(center_x+x,y+center_y);
end```
```        if j<=360 && j >270
lp(i,j)=img(center_x-x+1,y+center_y);
end```
```    end
end```

imshow(imrotate(p,-90));

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