フィルターのクリア

number of iteration

5 ビュー (過去 30 日間)
samia
samia 2011 年 5 月 2 日
I want to determine the number of iterations needed for the matrix its original state if a pixel is rotated according to a rule. for example to make the rotation I build this function:
%%%%%%%%%%%%%%
function nv_vect=catmap(N,a,b)
A=[1 a; b a*b+1];
nv_vect=zeros(2,N*N);
c=1;
for i=0:N-1
for j=0:N-1
nv_vect(:,c)=mod(A*[i j]',N);
c=c+1;
end
end
nv_vect=uint8(nv_vect+1);
%%%%%%%%%%%%%%%%
to construct the matrix I use this function:
function J=consruct_imag(I,nv_vect,N)
c=1;
for i=1:N
for j=1:N
J(i,j)=I(nv_vect(1,c),nv_vect(2,c));
c=c+1;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
now I will use the number of iteration to return the original image:
%%%%%%%%%%%%%%%%%%%%%%%%%
function J=cat_k_fois(I,N,a,b,k)
for g=1:k
nv_vect=catmap(N,a,b);
J=consruct_imag(I,nv_vect,N);
I=J;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I try to implement a function that allows me to determine the period T necessary to rebuild the image:
%%%%%%%%%%%%%%
function T=rech_k(I)
N=length(I);
a=1;k=1;k=1;
for(b=1:N-2)
while(k<=3*N)
K=cat_k_fois(I,N,a,b,k);
if(K==I)
T=k;break
else
k=k+1;
end
end
end
T;
%%%%%%%%%%%%%%%%%%%%%%
the problem is that the execution is very very slow, why??
  2 件のコメント
Oleg Komarov
Oleg Komarov 2011 年 5 月 2 日
Format the code properly and supply example inputs.
Use the profile and *preallocate*.
samia
samia 2011 年 5 月 4 日
if I understood you: my example is an image, I want to determine the period T if I change the image size; ie the main program is:
I=imread('image');
%% size(I)=N*N
T= rech_k(I);

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

回答 (0 件)

カテゴリ

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