Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Image to polar transformation...

Subject: Image to polar transformation...

From: amitesh kumar

Date: 18 Jan, 2011 17:10:05

Message: 1 of 8

Here below given code i have downloaded . bur it am unable to run it. its showing some error in imP = ImToPolar (imR ,rMin, RMax ,M, N).....
What exactly i should have to do excute to d below given program .plz tell me d exact steps involved in it.


function imP = ImToPolar (imR, rMin, rMax, M, N)
% IMTOPOLAR converts rectangular image to polar form. The output image is
% an MxN image with M points along the r axis and N points along the theta
% axis. The origin of the image is assumed to be at the center of the given
% image. The image is assumed to be grayscale.
% Bilinear interpolation is used to interpolate between points not exactly
% in the image.
%
% rMin and rMax should be between 0 and 1 and rMin < rMax. r = 0 is the
% center of the image and r = 1 is half the width or height of the image.
%
% V0.1 7 Dec 2007 (Created), Prakash Manandhar pmanandhar@umassd.edu

[Mr Nr] = size(imR); % size of rectangular image
Om = (Mr+1)/2; % co-ordinates of the center of the image
On = (Nr+1)/2;
sx = (Mr-1)/2; % scale factors
sy = (Nr-1)/2;

imP = zeros(M, N);

delR = (rMax - rMin)/(M-1);
delT = 2*pi/N;

% loop in radius and
for ri = 1:M
for ti = 1:N
    r = rMin + (ri - 1)*delR;
    t = (ti - 1)*delT;
    x = r*cos(t);
    y = r*sin(t);
    xR = x*sx + Om;
    yR = y*sy + On;
    imP (ri, ti) = interpolate (imR, xR, yR);
end
end

function v = interpolate (imR, xR, yR)
    xf = floor(xR);
    xc = ceil(xR);
    yf = floor(yR);
    yc = ceil(yR);
    if xf == xc & yc == yf
        v = imR (xc, yc);
    elseif xf == xc
        v = imR (xf, yf) + (yR - yf)*(imR (xf, yc) - imR (xf, yf));
    elseif yf == yc
        v = imR (xf, yf) + (xR - xf)*(imR (xc, yf) - imR (xf, yf));
    else
       A = [ xf yf xf*yf 1
             xf yc xf*yc 1
             xc yf xc*yf 1
             xc yc xc*yc 1 ];
       r = [ imR(xf, yf)
             imR(xf, yc)
             imR(xc, yf)
             imR(xc, yc) ];
       a = A\double(r);
       w = [xR yR xR*yR 1];
       v = w*a;
    end

Subject: Image to polar transformation...

From: Think blue, count two.

Date: 18 Jan, 2011 17:23:53

Message: 2 of 8

On 18/01/11 11:10 AM, amitesh kumar wrote:
> Here below given code i have downloaded . bur it am unable to run it.
> its showing some error in imP = ImToPolar (imR ,rMin, RMax ,M, N).....
> What exactly i should have to do excute to d below given program .plz
> tell me d exact steps involved in it.

The first step is to tell us what error you are seeing, and which Matlab
version you are using. If the error is happening at run-time then we
also need to know what you are passing in to the function.

Subject: Image to polar transformation...

From: amitesh kumar

Date: 19 Jan, 2011 04:59:22

Message: 3 of 8

"Think blue, count two." <roberson@hushmail.com> wrote in message <J0kZo.3034$134.837@newsfe01.iad>...
> On 18/01/11 11:10 AM, amitesh kumar wrote:
> > Here below given code i have downloaded . bur it am unable to run it.
> > its showing some error in imP = ImToPolar (imR ,rMin, RMax ,M, N).....
> > What exactly i should have to do excute to d below given program .plz
> > tell me d exact steps involved in it.
>
> The first step is to tell us what error you are seeing, and which Matlab
> version you are using. If the error is happening at run-time then we
> also need to know what you are passing in to the function.


here i am sending the link of original source code file.plz let me know how i have to run it.
I am using MATLAB 7.9.0(R2009b).

http://www.mathworks.com/matlabcentral/fileexchange/17933

When i am trying after runing program it showing the following error......
??? Undefined function or method 'ImToPolar' for input arguments of type 'double'.

Error in ==> check at 5
imP = ImToPolar(im, 0.6, 1, 40, 200);
 


I want to change rectangular image in log-polar formate. In this i am feeling so much difficulty so plz help me to sort out dis problem. thanx a lot for ur cooperations.....

Subject: Image to polar transformation...

From: ImageAnalyst

Date: 19 Jan, 2011 11:16:08

Message: 4 of 8

Maybe it wants uint8 images? I didn't download it so I don't know,
but often images are expected to be uint8, and apparently you're
trying to pass it a double.

Subject: Image to polar transformation...

From: Think blue, count two.

Date: 19 Jan, 2011 17:19:25

Message: 5 of 8

On 18/01/11 10:59 PM, amitesh kumar wrote:

> here i am sending the link of original source code file.plz let me know
> how i have to run it.
> I am using MATLAB 7.9.0(R2009b).
> http://www.mathworks.com/matlabcentral/fileexchange/17933
>
> When i am trying after runing program it showing the following error......
> ??? Undefined function or method 'ImToPolar' for input arguments of type
> 'double'.
>
> Error in ==> check at 5
> imP = ImToPolar(im, 0.6, 1, 40, 200);

Try

which -all ImToPolar

I suspect it is not on your Matlab path. I note that the zip file
contents list a subdirectory name before every file name; if your
current directory is not that subdirectory and the subdirectory is not
in your matlab path, then matlab would not be able to find the source.

Subject: Image to polar transformation...

From: amitesh kumar

Date: 20 Jan, 2011 07:16:04

Message: 6 of 8

"Think blue, count two." <roberson@hushmail.com> wrote in message <x2FZo.34333$bd2.16033@newsfe12.iad>...
> On 18/01/11 10:59 PM, amitesh kumar wrote:
>
> > here i am sending the link of original source code file.plz let me know
> > how i have to run it.
> > I am using MATLAB 7.9.0(R2009b).
> > http://www.mathworks.com/matlabcentral/fileexchange/17933
> >
> > When i am trying after runing program it showing the following error......
> > ??? Undefined function or method 'ImToPolar' for input arguments of type
> > 'double'.
> >
> > Error in ==> check at 5
> > imP = ImToPolar(im, 0.6, 1, 40, 200);
>
> Try
>
> which -all ImToPolar
>
> I suspect it is not on your Matlab path. I note that the zip file
> contents list a subdirectory name before every file name; if your
> current directory is not that subdirectory and the subdirectory is not
> in your matlab path, then matlab would not be able to find the source.


thnx a lot sir....u helped me a lot..finally i got it...i would expect help from U in future also.

Subject: Image to polar transformation...

From: David Young

Date: 20 Jan, 2011 11:31:05

Message: 7 of 8

"amitesh kumar" wrote in message <ih5r3a$gbu$1@fred.mathworks.com>...
> ...
> I want to change rectangular image in log-polar formate. In this i am feeling so much difficulty so plz help me to sort out dis problem. thanx a lot for ur cooperations.....

I think your downloaded code is for a polar transformation, not log-polar. If you want a log-polar transform, you could download this file exchange submission:

http://www.mathworks.com/matlabcentral/fileexchange/27093-affine-optic-flow

You can ignore most of it, just use logsample.m (which calls logtform). You need the Image Processing Toolbox as well. The file also includes logsampback in case you want to reverse the transform.

Subject: Image to polar transformation...

From: amitesh kumar

Date: 1 Feb, 2011 11:30:14

Message: 8 of 8

"David Young" wrote in message <ih96do$jas$1@fred.mathworks.com>...
> "amitesh kumar" wrote in message <ih5r3a$gbu$1@fred.mathworks.com>...
> > ...
> > I want to change rectangular image in log-polar formate. In this i am feeling so much difficulty so plz help me to sort out dis problem. thanx a lot for ur cooperations.....
>
> I think your downloaded code is for a polar transformation, not log-polar. If you want a log-polar transform, you could download this file exchange submission:
>
> http://www.mathworks.com/matlabcentral/fileexchange/27093-affine-optic-flow
>
> You can ignore most of it, just use logsample.m (which calls logtform). You need the Image Processing Toolbox as well. The file also includes logsampback in case you want to reverse the transform.

Hello Sir

As u suggested me i had downloaded the above file . from that files i just used logsample.m . This file is saved in d functional form. but whn i m trying to call it showing some error.

logarr = logsample(arr, rmin, rmax, xc, yc, nr, nw)

as per above statement i am putting value arr, rmin,rmax (between 0 &1), xc and yc (512,512 as size of my image is 512*512) and value of nr and nw putiing 5 &12 respectively.

now my whole implementation in matlab is as follows
I = imread('lena.jpg');
I = double(I)/255.0;
    figure(1)
    imshow(I)
    
    
J = fft(I);
    figure(2)
    S = abs(J);
    imshow(S)

    
   logarr = logsample(S , 0.6 , 1.0 , 512,512 , 5, 12);
   figure(3)
   imshow(logarr)

and after running i am getting error as follows..
??? Undefined function or method 'logtform' for input arguments of type 'double'.

Error in ==> logsample at 62
t = logtform(rmin, rmax, nr, nw);

Error in ==> l2t at 8
   logarr = logsample(I,0.6, 1.0, 512,512,5,12);

my image is gray having size is 512*512. here i just took logsample.m from the file and save it as function and here i am trying to use it in the above mentioned way. at which step i am doing mistake plz xplain me .
 

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us