How to reduce for loops?

Hello, I am currently working on 2-Dimensional Hartley transform.The code is shown below:
clc;clear all;close all;
img =imread('101_7.tif');
figure;imshow(img);
X = zeros(size(img,1),size(img,2));
for u=1:size(img,1)
for v=1:size(img,2)
for x=1:size(img,1)
for y=1:size(img,2)
a = 2*pi*u*x/size(img,1);
b = 2*pi*v*y/size(img,2);
temp= img(x,y)*(cos(a+b) + sin(a+b));
X(u,v)= X(u,v)+temp;
end
end
end
end
It has 4 for loops and it takes a very long time to execute this. Is there any method to make it more efficient by reducing the for loops? Anything regarding this would be very helpful.
The formula used for this 2-D Hartley transform is shown below:
Reference:Separable two-dimensional discrete Hartley transform by Andrew B. Watson and Allen Poirson.
Thank you.

Answers (0)

Categories

Asked:

on 11 Dec 2015

Edited:

on 21 May 2016

Community Treasure Hunt

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

Start Hunting!