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.
댓글 수: 1
cbentter
2016년 5월 21일
This work could help you: FAST ALGORITHMS OF FOURIER AND HARTLEY TRANSFORM AND THEIR IMPLEMENTATION IN MATLAB by VíTÌZSLAV VESELÝ
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Transforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!