필터 지우기
필터 지우기

Need Help Regarding Log-Map of Images

조회 수: 2 (최근 30일)
Abdullah Khan
Abdullah Khan 2013년 7월 2일
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
Walter Roberson
Walter Roberson 2013년 7월 2일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Alex Taylor
Alex Taylor 2013년 7월 2일
편집: Alex Taylor 2013년 7월 2일
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

추가 답변 (1개)

Abdullah Khan
Abdullah Khan 2013년 7월 3일
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;
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))));
y=abs(round(exp(log(i))*sin(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
Your help is highly appreciated

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by