Hi every one >> hope you all are doing fine
I wanted to ask you about calculating the phase values for an image ,, you see I used the Gabor wavlet like so :
k = ( Kmax / ( f ^ v ) ) * exp( 1i * u * pi / 8 );% Wave Vector
kn2 = ( abs( k ) ) ^ 2;
GW = zeros ( R , C );
for m = -R/2 + 1 : R/2
for n = -C/2 + 1 : C/2
GW(m+R/2,n+C/2) = ( kn2 / Delt2 ) * exp( -0.5 * kn2 * ( m ^ 2 + n ^ 2 ) / Delt2) * ( exp( 1i * ( real( k ) * m + imag ( k ) * n ) ) - exp ( -0.5 * Delt2 ) );
end
end
I=imread('a.pgm');
Myimage=conv2(I,double(GW),'same');
then I called the image and the filter with different orientations and scales and stored the phase in P then I wanted to quantize it with rang 4 i:
close all;
clear all;
clc;
% Parameter Setting
R = 32;
C = 32;
Kmax = pi;
f = sqrt( 2 );
Delt = 2 * pi;
Delt2 = Delt * Delt;
% Show the Gabor Wavelets
for v=1:7 %v = 1 : 7
for u = 1:5 % u= 1: 5
[GW,Myimage]= GaborWavelet ( R, C, Kmax, f, u, v, Delt2 ); % Create the Gabor wavelets
figure;
subplot( 5, 8, v * 7 + u ),imshow ( real( GW ) ,[]); % Show the real part of Gabor wavelets
end
figure ;
subplot( 1, 5, v + 1 ),imshow ( abs( GW ),[]); % Show the magnitude of Gabor wavelets
end
%clear I;
R=real(GW);
I=imag(GW);
M=abs(Myimage);
P=atan(imag(Myimage)/real(Myimage)); <<<< is this even right ??
%P=atan(I/R);
save P P;
[xx,yy] = size (P);
DATA =zeros(size(P));
for i=1:48
for j=1:48
for zz=1:3
if (360* zz/4) <= abs(P(i,j))&& abs(P(i,j))<(360*(zz+1)/4)
DATA(i,j)=zz ; end;
end;
end;
end;
save DATA DATA ;
But the data is so small like : -1.49279186693682 1.50990968797986 -1.39225915272978 0.966151874072431
which leads to quantized value of 0 >> Where did I go wrong
I think values seem small because they are given in radians and you expect them in degrees. As for getting the magnitude and angle of a complex number, take a look at http://www.mathworks.fr/fr/help/matlab/ref/angle.html.
I quote:
"For complex Z, the magnitude R and phase angle theta are given by
R = abs(Z)
theta = angle(Z)"
Z would be your GW.
Hope this helps!
Related
Hi I am looking for some help to optimize some Matlab code. I have an input matrix M, which is Ny rows by Nx columns. I would like to define a boundary all the way round the edge of the matrix where the values should be attenuated smoothly down to zero. To do this, I attempted to define a masking function MSK and multiply it point by point to get an output N, shown below:
My attempt above was created using the code below, where I use a cosine squared function to get the smooth drop off from 1 to zero:
%%% Set up some grids %%%
Nx = 128;
Ny = 64;
dx = 0.1;
dy = 0.1;
x = -(Nx*dx/2):dx:(Nx*dx/2-dx);
y = -(Ny*dy/2):dy:(Ny*dy/2-dy);
x = permute(x, [1 2 3]); % Creates a [1 x Nx x 1] vector (saves memory)
y = permute(y, [2 1 3]); % Creates a [Ny x 1 x 1] vector
M = complex( double( rand(Ny,Nx)+10 ) ); % Create some input data
bnd_frac = 0.7; % The fraction of the grid to begin masking boundary, i.e 70% of the grid max
MSK = create_mask_function(x,y,Nx,Ny,bnd_frac); % Create masking function
N = M.*MSK; % Apply mask to input data, to smoothly ramp edges to zero
figure;
subplot(1,3,1);imagesc(x,y, abs(M) )
subplot(1,3,2);imagesc(x,y, abs(MSK) )
subplot(1,3,3);imagesc(x,y, abs(N) )
%%%%%%%%%%%%%%%%%%%%%%%%
%%% Masking Function %%%
%%%%%%%%%%%%%%%%%%%%%%%%
function MSK = create_mask_function(x,y,Nx,Ny,bnd_frac)
[~,bndind_x] = min( abs(x - bnd_frac*x(Nx)) ); % Find the index to begin the masking
x_bound = x(bndind_x); % Find the grid coordinate to begin masking
[~,bndind_y] = min( abs(y - bnd_frac*y(Ny)) );
y_bound = y(bndind_y);
dbnd_xp = x(Nx) - x_bound; % Find the width of the boundary region at each edge
dbnd_xm = x(1) + x_bound;
dbnd_yp = y(Ny) - y_bound;
dbnd_ym = y(1) + y_bound;
MSK = ones(Ny,Nx); % Initialise the mask matrix as ones
% Set the values within each boundary region at the edge to ramp smoothly to 0 from 1
MSK( : , x > x_bound ) = repmat( ( cos( ( x(x>+x_bound) - x_bound )/dbnd_xp * pi/2 ) ).^2 , Ny , 1);
MSK( : , x < -x_bound ) = repmat( ( cos( ( x(x<-x_bound) + x_bound )/dbnd_xm * pi/2 ) ).^2 , Ny , 1);
MSK( y > y_bound , : ) = repmat( ( cos( ( y(y>+y_bound) - y_bound )/dbnd_yp * pi/2 ) ).^2 , 1 , Nx);
MSK( y < -y_bound , : ) = repmat( ( cos( ( y(y<-y_bound) + y_bound )/dbnd_ym * pi/2 ) ).^2 , 1 , Nx);
MSK(:,Nx,:) = 0;
MSK(:,1,:) = 0;
MSK(Ny,:,:) = 0;
MSK(1,:,:) = 0;
end
The problem with the code above is that it allocates too much memory to MSK.
(In the real version of my code, all of of the matrices are 3D, and the sizes can be more like 1024x512x512 in reality, but I have made a simplifed 2D example here to help explain.)
Note that this is the reason that I am using permute() on the x and y vectors above, because other parts of my full code use Matlab's implicit expansion. This is to avoid storing 3D versions of x and y that have been generated using meshgrid().
It is clear in the above image that MSK contains mostly values of 1, and the ramping values only occur near the edges. So this seems like large waste of memory to store those 1's because their purpose is to just make sure the input matrix is not modified in the centre. Can anyone help me understand a way in Matlab to implement what I want but in a way that will use less RAM?
If you can't store, then you need to recompute the weights each time and use them on the fly.
The short answer then is that instead of some precomputing of MSK and then usage later, as:
MSK( : , x > x_bound ) = repmat( ( cos( ( x(x>+x_bound) - x_bound )/dbnd_xp * pi/2 ) ).^2 , Ny , 1);
etc()
...
N = M.*MSK
You want to just, on the fly:
N( : , x > x_bound ) = M( : , x > x_bound ).*repmat( ( cos( ( x(x>+x_bound) - x_bound )/dbnd_xp * pi/2 ) ).^2 , Ny , 1);
etc()
I'll leave how you restructure the code to you, but I'd basically just add the matrix M as input to your function, and rename it to "apply_mask" or something like that. There will likely be ways to optimize this further if needed, but "early optimization is the root of all evil".
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have written a small code that is supposed to verify that ( x + d/dx ) exp(-x^2 / 2 ) = 0. The idea is to use a Fourier series exp( 2 * pi j n x / L ) with sufficiently large L to represent the Gaussian and perform the operation there.
The algorithm in Matlab works as follows:
function[] = verify
epsilon = 0.05; % step-size numerical integration
N = 40; % number of Fourier coefficients
L = 30; % window length numerical integration Fourier basis
X = -L / 2:epsilon:L / 2; % grid
xFourier = zeros(2 * N + 1); %Allocate space for Fourier coefficients of f(x)=x
inix = zeros(2 * N + 1); % Allocate space for Fourier coefficients of f(x)=exp(-x^2/2)
% Compute Fourier coefficients of f(x)=x
for i1=-N:N
A = X.*exp(-2 * pi * 1i * i1. * X / L ) / sqrt( L );
xFourier(i1 + ( N + 1 ) ) = trapz( X, A );
end
% Compute Fourier coefficients of f(x)=exp(-x^2/2)
for i1 = -N : N
A = 1 / sqrt(L) * exp(-X.^2 / 2 ). * exp(-2 * pi * 1i * i1. * X / L );
inix( i1 + N + 1 ) = trapz( X, A ); % These are the Fourier coefficients of the |x|^2*Gaussian part
end
TO = Hamilton( N, xFourier, L );
norm( TO * inix' )
end
So the heart of the above algorithm is the function Hamilton that I am calling, it contains the matrix representation of the operator x d/dx, which is why norm( TO * inix' ) should return something close to zero, but it does not(?) and the function Hamilton is as follows
function [ Hamilton ] = Hamilton( N, xFourier, L)
Hamilton = zeros( ( 2 * N + 1 ),( 2 * N + 1 ) );
for i1 = -N : N
for i2 = -N : N
if i1 == i2
Hamilton(
(i1 + ( N + 1 ) ), ( i2 + ( N + 1 ) )
) = Hamilton(
( i1 + ( N + 1)),( i2 + ( N + 1 ) )
) + 1i * 2 * pi / L * i1;
end
if abs( i2 - i1 ) <= N
Hamilton(
( i1 + ( N + 1 ) ), ( i2 + ( N + 1 ) )
) = Hamilton(
(i1 + ( N + 1 ) ), ( i2 + ( N + 1 ) )
) + xFourier( i1 - i2 + ( N + 1 ) );
end
end
end
end
Does anybody see a mistake?
While not into Matlab , I somewhat miss a few terms in the code, like the factor 2 pi j k for the derivative. So here I put a Python version of what I think it should look like (sorry for the Python, but I guess it translates to Matlab quite easily):
import numpy as np
## non-normalized gaussian with sigma=1
def gauss( x ):
return np.exp( -x**2 / 2 )
## interval on which the gaussian is evaluated
L = 10
## number of sampling points
N = 21
## sample rate
dl = L / N
## highest frequency detectable
kmax= 1 / ( 2 * dl )
## array of x values
xl = np.linspace( -L/2, L/2, N )
## array of k values
kl = np.linspace( -kmax, kmax, N )
## matrix of exponents
## the Fourier transform is defined via sum f * exp( -2 pi j k x)
## i.e. the 2 pi is in the exponent
## normalization is sqrt(N) where n is the number of sampling points
## this definition makes it forward-backward symmetric
## "outer" also exists in Matlab and basically does the same
exponent = np.outer( -1j * 2 * np.pi * kl, xl )
## linear operator for the standard Fourier transformation
A = np.exp( exponent ) / np.sqrt( N )
## nth derivative is given via partial integration as ( 2 pi j k)^n f(k)
## every row needs to be multiplied by the according k
B = np.array( [ 1j * 2 * np.pi * kk * An for kk, An in zip( kl, A ) ] )
## for the part with the linear term, every column needs to be multiplied
## by the according x or--as here---every row is multiplied element
## wise with the x-vector
C = np.array( [ xl * An for An in A ] )
## thats the according linear operator
D = B + C
## the gaussian
yl = gauss( xl )
## the transformation with the linear operator
print( np.dot( D, yl ).round( decimals=9 ) )
## ...results in a zero-vector, as expected
provides:
[ 0.+4.61e-07j 0.-3.75e-07j 0.+1.20e-08j 0.+3.09e-07j -0.-5.53e-07j
0.+6.95e-07j -0.-7.28e-07j 0.+6.54e-07j -0.-4.91e-07j -0.+2.62e-07j
-0.+0.00e+00j -0.-2.62e-07j -0.+4.91e-07j -0.-6.54e-07j 0.+7.28e-07j
-0.-6.95e-07j 0.+5.53e-07j -0.-3.09e-07j 0.-1.20e-08j 0.+3.75e-07j
0.-4.61e-07j]
This is basically zero.
I am trying to make LK and HS original algorithm robust using Black & Anandan Lorentzian method
I did not know how to apply this concept in my MATLAB code ! ... and when I tried to apply what I know I got worse results than the original HS
I will attach my MATLAB code ... if any one have any idea how to do it ... or where is my mistakes .. I will be appreciate it
this code read 4 gray images (i0, i1, i2, i3)
the actual robustness process in perform_reg_iter ( I tried to applied to data and smoothing term ) but it gives me worse flow than the original method
function [regularized_u,regularized_v]=regularization_robust (i0,i1,i2,i3)
alpha=10.0;
numpass=100;
ROBUST_FLAG = true;
[pic_x, pic_y]=size(i0);
I=cell(1,2);
I{1,1}=double(box_filter(i0,i1,i2));
I{1,2}=double(box_filter(i1,i2,i3));
%Simocelli
[Ix,Iy,It]=apply_Simoncelli_filters(I{1,1},I{1,2});
[row, col]= size(Ix);
%%%caculate the flow %%%%%%
[regularized_u,regularized_v]= calc_intensity_regularization_flow(Ix,Iy,It,alpha,numpass, ROBUST_FLAG);
%%%%% print output
end
function [seq]=box_filter(seq1,seq2,seq3)
box(1)=0.25;
box(2)=0.5;
box(3)=0.25;
seq=box(1)*seq1+box(2)*seq2+box(3)*seq3;
temp=imfilter(seq,box,'same','conv','symmetric');
seq=imfilter(temp,box','same','conv','symmetric');
end % box_filter
function [Ix,Iy,It]=apply_Simoncelli_filters(I1,I2)
It=I2-I1;
gd=[1 -8 0 8 -1]/12;
Ix=-imfilter(I1,gd,'conv','symmetric','same');
Iy=-imfilter(I1,gd','conv','symmetric','same');
end
% Robust function
function [y]= robust_functions (type, x, sigma, order)
switch (type)
case 'lorentzian'
switch (order)
case 0
y = log(1 + x.^2 / (2 * sigma^2));
case 1
y = 2 * x ./ (2 * sigma^2 + x.^2);
if (2 * sigma^2 + x.^2) ==0
y = 100;
end
case 2
y = 2 ./ (2 * sigma^2 + x.^2);
end
case 'quadratic'
switch (order)
case 0
y = x.^2 / sigma^2;
case 1
y = 2 * x / sigma^2;
case 2
y = repmat(2 / sigma^2, size(x));
end
otherwise
error('Invalid robust function type.');
end
end
function [regularized_u,regularized_v]=...
calc_intensity_regularization_flow(Ix,Iy,It,alpha,numpass,ROBUST_FLAG)
regularized_u=zeros(size(Ix),'double');
regularized_v=zeros(size(Iy),'double');
% Perform iterations
for iter_no=0:2:numpass
[u2,v2]=perform_reg_iter(regularized_u,regularized_v,...
Ix,Iy,It,alpha,ROBUST_FLAG);
[regularized_u,regularized_v]=perform_reg_iter(u2,v2,Ix,Iy,It,...
alpha,ROBUST_FLAG);
end
end
function [u,v]=perform_reg_iter(u,v,Ix,Iy,It,alpha,ROBUST_FLAG)
kernel_1=[1/12 1/6 1/12;1/6 0 1/6;1/12 1/6 1/12];
estimator_weight=0.0;
robust_type= 'lorentzian'; % 'lorentzian'; % charbonnier
% (0) original ... (1) first derivative ... (2) 2 ./ (2 * sigma^2 + x.^2)
% in Sun paper
robust_order=2;
uAvg=conv2(u,kernel_1,'same');
vAvg=conv2(v,kernel_1,'same');
if (ROBUST_FLAG)
% Smoothing term
% robust_sigma =1; %0.03 in Sun paper
%uAvg = feval('robust_functions',robust_type,uAvg,robust_sigma,robust_order);
%vAvg = feval('robust_functions',robust_type,vAvg,robust_sigma,robust_order);
%Data term
robust_sigma=0.01; % 1.5 in Sun paper
value = Ix.*u + Iy.*v + It;
estimator_weight =
feval('robust_functions',robust_type,value,robust_sigma,robust_order);
Ix= Ix.* estimator_weight;
Iy= Iy.* estimator_weight;
It= It.* estimator_weight;
end
u= uAvg - ( Ix .* ( ( Ix .* uAvg ) + ( Iy .* vAvg ) + It ) ) ./ ...
( alpha^2 + Ix.^2 + Iy.^2);
v= vAvg - ( Iy .* ( ( Ix .* uAvg ) + ( Iy .* vAvg ) + It ) ) ./ ...
( alpha^2 + Ix.^2 + Iy.^2);
end
Without Robust calculation I got this results
with the robust I got this result
I have two physical "objects." I am representing their positions with two different arrays.
• Object 1 moves in the xy-plane only
• Object 2 moves in all three physical dimensions
Objective: Vectorize the four for loops without distorting the data. Also, the intent is to perform this operation for all possible values of object 1 to be compared with object 2.
Here is the code snippet:
Npos = 21;
Nsam = 200;
% dummy initialisation
AX = rand(1, Npos);
AY = zeros(1, Npos);
AZ = rand(1, Npos);
Bx = rand(Nsam);
By = rand(Nsam);
Bz = rand(Nsam);
for qx = 1 : Npos
for yx = 1 : Npos
for zx = 1 : Nsam
for cx = 1 : Nsam
Tx2Array( qx, yx, zx, cx ) = sqrt( ( AX( qx ) - Bx( zx, cx ) ).^2 + ( AY( yx ) - By( zx, cx ) ).^2 + ( AZ( yx ) - Bz( zx, cx ) ).^2 );
end
end
end
end
% Result is a 21 x 21 x 200 x 200 matrix filled with all real numbers
Legend
AX, AY, AZ are 1 x 21 arrays and represent the (x,y=0,z) of Object 1
AY is all zeros, but for readability is still included (hence no fifth loop!)
Bx, By, Bz are all 200 x 200 arrays and represent the (x,y,z) of Object 2
Npos = 21; Nsam = 200;
The formula used above is:
sqrt( (a1-b1)^2 + (a2-b2)^2 + (a3-b3)^2 )
If you have the Statistics Toolbox available, you can use pdist2 to calculate the distance between each coordinate for Object 1 and each coordinate for Object 2:
[X1, Z1] = ndgrid(AX(:), AZ(:)); % X1 and Z1 will be 21x21
D = pdist2([X1(:), zeros(size(X1(:))), Z1(:)], [Bx(:), By(:), Bz(:)]);
The output in this case will be a 441 x 40,000 array where D(i, j) gives you the distance between point i of Object 1 and point j of Object 2, both using linear indexing.
You can avoid the to inner loops by replacing zx and cx with : as follows:
Tx2Array = zeros(Npos, Npos, Nsam, Nsam); % preallocate memory
for qx = 1 : Npos
for yx = 1 : Npos
Tx2Array( qx, yx, :, : ) = sqrt( ( AX( qx ) - Bx( :, : ) ).^2 + ( AY( yx ) - By( :, : ) ).^2 + ( AZ( yx ) - Bz( :, : ) ).^2 );
end
end
In this way, the largest dimensions are vectorised. So, the largest improvement is already done.
By converting your B* to 4D and generating a mesh for your A* matrices, you can even remove all the for loops as follows:
[AX_, AZ_] = meshgrid(AX, AZ);
AX_ = AX_';
AZ_ = AZ_';
AY_ = zeros(Npos);
Bx_(1, 1, :, :) = Bx;
By_(1, 1, :, :) = By;
Bz_(1, 1, :, :) = Bz;
Tx2Array2 = sqrt( ( AX_ - Bx_ ).^2 + ( AY_ - By_ ).^2 + ( AZ_ - Bz_ ).^2 );
You can check the the results are the same using the following check:
max(max(max(max(abs(Tx2Array - Tx2Array2))))) < eps
If the arrays are correctly initialized your task will be very simple:
Initialize the arrays with the correct dimensions
AX = rand( Npos,1);
AY = zeros(1, Npos);
AZ = rand(1, Npos);
Bx = rand(1,1,Nsam,Nsam);
By = rand(1,1,Nsam,Nsam);
Bz = rand(1,1,Nsam,Nsam);
Then in MATLAB r2016b / Octave you can simply write:
Tx2Array = sqrt( ( AX - Bx ).^2 + ( AY - By ).^2 + ( AZ - Bz ).^2 );
In pre r2016b you can use bsxfun:
Tx2Array = sqrt(bsxfun(#plus,bsxfun(#plus,bsxfun(#minus,AX , Bx).^2,bsxfun(#minus,AY , By).^2),bsxfun(#minus,AZ , Bz).^2));
I am looking for a MATLAB solution to generate the matrix representation of a discrete Radon transform (DRT). That is, given a vectorized version of an MxN image, X, I'd like to generate the matrix R such that R*X(:) is a DRT of the image. In MATLAB, I am expecting it to look something like the following:
>> X = 2D_Image_Of_Size_MxN;
>> R = DRT_Matrix_Of_Size_LPxMN;
>> DRT = reshape( R * X(:), L, P );
I know there are several ways to define a DRT, so I'll just say that I am looking for a normal or standard or not-too-out-of-the-ordinary implmentation.
function [ R rho theta ] = radonmatrix( drho, dtheta, M, N )
% radonmatrix - Discrete Radon Trasnform matrix
%
% SYNOPSIS
% [ R rho theta ] = radonmatrix( drho, dtheta, M, N )
%
% DESCRIPTION
% Returns a matrix representation of a Discrete Radon
% Transform (DRT).
%
% INPUT
% drho Radial spacing the the DRT.
% dtheta Angular spacing of the DRT (rad).
% M Number of rows in the image.
% N Number of columns in the image.
%
% OUTPUT
% R LP x MN DRT matrix. The values of the L and
% P will depend on the radial and angular spacings.
% rho Vector of radial sample locations.
% theta Vector of angular sample locations (rad).
%
% For each angle, we define a set of rays parameterized
% by rho. We then find the pixels on the MxN grid that
% are closest to each line. The elements in R corresponding
% to those pixels are given the value of 1.
% The maximum extent of the region of support. It's for
% rho = 0 and theta = pi/4, the line that runs caddy-corner.
W = sqrt( M^2 + N^2 );
rho = -W/2 : drho : W/2;
theta = 0 : dtheta : 180 - dtheta;
L = length( rho );
P = length( theta );
R = false( L*P, M*N );
% Define a meshgrid w/ (0,0) in the middle that
% we can use a standard coordinate system.
[ mimg nimg ] = imggrid( 1, 1, [ M N ] );
% We loop over each angle and define all of the lines.
% We then just figure out which indices each line goes
% through and put a 1 there.
for ii = 1 : P
phi = theta(ii) * pi/180;
% The equaiton is rho = m * sin(phi) + n * cos(phi).
% We either define a vector for m and solve for n
% or vice versa. We chose which one based on angle
% so that we never g4et close to dividing by zero.
if( phi >= pi/4 && phi <= 3*pi/4 )
t = -W : min( 1/sqrt(2), 1/abs(cot(phi)) ) : +W;
T = length( t );
rhom = repmat( rho(:), 1, T );
tn = repmat( t(:)', L, 1 );
mline = ( rhom - tn * cos(phi) ) ./ sin(phi);
for jj = 1 : L
p = round( tn(jj,:) - min( nimg ) ) + 1;
q = round( mline(jj,:) - min( mimg ) ) + 1;
inds = p >= 1 & p <= N & q >= 1 & q <= M;
R( (ii-1)*L + jj, unique( sub2ind( [ M N ], q(inds), p(inds) ) ) ) = 1;
end
else
t = -W : min( 1/sqrt(2), 1/abs(tan(phi)) ) : +W;
T = length( t );
rhon = repmat( rho(:)', T, 1 );
tm = repmat( t(:), 1, L );
nline = ( rhon - tm * sin(phi) ) ./ cos(phi);
for jj = 1 : L
p = round( nline(:,jj) - min( nimg ) ) + 1;
q = round( tm(:,jj) - min( mimg ) ) + 1;
inds = p >= 1 & p <= N & q >= 1 & q <= M;
R( (ii-1)*L + jj, unique( sub2ind( [ M N ], q(inds), p(inds) ) ) ) = 1;
end
end
end
R = double( sparse( R ) );
return;
Here is the imggrid function used in the above.
function [ m n ] = imggrid( dm, dn, sz )
% imggrid -- Returns rectilinear coordinate vectors
%
% SYNOPSIS
% [ m n ] = imggrid( dm, dn, sz )
%
% DESCRIPTION
% Given the sample spacings and the image size, this
% function returns the row and column coordinate vectors
% for the image. Both vectors are centered about zero.
%
% INPUT
% dm Spacing between rows.
% dn Spacing between columns.
% sz 2x1 vector of the image size: [ Nrows Ncols ].
%
% OUTPUT
% m sz(1) x 1 row coordinate vector.
% n 1 x sz(2) column coordinate vector.
M = sz(1);
N = sz(2);
if( mod( M, 2 ) == 0 )
m = dm * ( ceil( -M/2 ) : floor( M/2 ) - 1 )';
else
m = dm * ( ceil( -M/2 ) : floor( M/2 ) )';
end
if( mod( N, 2 ) == 0 )
n = dn * ( ceil( -N/2 ) : floor( N/2 ) - 1 );
else
n = dn * ( ceil( -N/2 ) : floor( N/2 ) );
end
image = phantom();
projection = radon(image);
R = linsolve(reshape(image,1,[]), reshape(projection,1,[]));