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
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 plot(X,Y,'.');
logPolarImage = interp2(double(a),X,Y);
figure, imagesc(logPolarImage); colormap gray
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);
for i=1:size_lmap_r for j=1:size_lmap_t
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
i have also attached results for a non rotaed and -90 degree rotated picture
Your help is highly appreciated