필터 지우기
필터 지우기

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 CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by