フィルターのクリア

Reduction of code lines

1 回表示 (過去 30 日間)
Ayesha
Ayesha 2014 年 1 月 21 日
編集済み: Walter Roberson 2014 年 1 月 21 日
Alright, so I've written this particular thing to blur an image and I've been wondering if I could reduce the number of lines or perhaps cut down the redundancies within this code especially the last line which copies one matrix to an other. Any over the top ideas would also be appreciated!
a=512;
b = a^2/16;
c=(sqrt(b)-1)/2;
ft11 = fftshift(fft2(myImage));
width = size(myImage,1);
F1 = zeros(width);
d = width/2;
e = (d-c:d+c)+1;
ft11(e,e)=F1(e,e);

採用された回答

Walter Roberson
Walter Roberson 2014 年 1 月 21 日
編集済み: Walter Roberson 2014 年 1 月 21 日
a = 512;
B = a/4;
c = (B-1)/2;
ft11 = fftshift(fft2(myImage));
width = size(myImage,1);
d = width/2;
e = (d-c:d+c)+1;
ft11(e,e) = 0;

その他の回答 (1 件)

Amit
Amit 2014 年 1 月 21 日
Its a good code. The only place I think there is a chance is
a=512;
b = a^2/16;
c=(sqrt(b)-1)/2;
ft11 = fftshift(fft2(myImage));
width = size(myImage,1);
%F1 = zeros(width); % You dont need to store these zeros
d = width/2;
e = (d-c:d+c)+1;
ft11(e,e)=zeros(e);
  1 件のコメント
Amit
Amit 2014 年 1 月 21 日
編集済み: Amit 2014 年 1 月 21 日
you might think of putting (d-c:d+c)+1 directly. However this might create more overhead, due to temporary storing those values (3 times). (I might be wrong about this)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by