Thursday, April 12. 2007Images to vectors: Algorithm![]()
Given an image im of size p×q with gcd(p,q)=1.
Let’s try this with our zebra. In my previous tries I simply took p=479 and q=480 to have gcd(479,480)=1, but 479 is a prime number and I therefore have no possibility to divide it by some step size. For GA I have to lay some kind of lattice over the image. So there is actually a second condition forbidding p and q to be prime. I take p=473 instead, it has 11 and 43 as divisors. > im=img(4:476,:);
> [p q]=size(im), N=p*q
p = 473
q = 480
N = 227040
> alldiv(N)(1:13)
ans =
2 3 4 5 6 8 10 11 12 15 16 20 22 As one can see, N has many divisors, but e.g. 19 is not one of them. We can’t take e.g. 9 although it doesn’t occur either, as it is divided by 3, which is a divisor of N. Taking such a wrong step size will lead one back to the first pixel too early and one can never span the whole image. > s=9; idx=mod((1:s:N*s)-1, N)+1;
> find(idx==1)
ans =
1 75681 151361
> s=19; idx=mod((1:s:N*s)-1, N)+1;
> find(idx==1)
ans = 1
> find(idx==2)
ans = 23900
> imv(idx) = im(:);
> plot(imv) And now the other way round:
> rim=reshape(imv(idx),p,q);
> size(rim)
ans =
473 480
> imagesc(rim) ![]()
By the way, another try of comparing the FFT of the vector with the FFT2 of the image shows again that one cannot get the FFT2 by doing an FFT of the vector. This is because the line-patterns in the image might not be preserved under that transform, as neighboring pixels might not become neighbors in the resulting vector. Wednesday, April 11. 2007Unjodiert jodiert![]() Wednesday, April 4. 2007Images to vectors: Quick index matrix![]()
I found a quicker way to compute the index matrix I mentioned:
> tic; [jj kk]=meshgrid(1:p,1:q); toc
Elapsed time is 0.080879 seconds.
> size(jj), size(kk)
ans =
479 480
ans =
479 480
> tic; idx=mod(b*q*jj+a*p*kk,N)’; toc
Elapsed time is 0.129128 seconds.
> idx(p,q)=N; %valid index value
> imv=zeros(1,N);
> tic; for j=1:p; for k=1:q;
> imv(idx(j,k)) = im(j,k);
> end; end; toc
Elapsed time is 6.770042 seconds. So nothing with 58 seconds anymore. ![]() Tuesday, April 3. 2007Images to vectors and back![]() Regarding the previous questions I noticed that GA on LCA groups is too general for my concerns and that the study of GA on finite abelian groups is enough.
In a certain paper HGFei published a result that for p×q-images where p and q are relatively prime there is an isomorphism to a vector of length N=pq. The theory considers the groups
> im=img(2:480,:);
> size(im)
ans =
479 480
> gcd(479,480)
ans = 1
Just for a first test I set α=p and β=q and define a primitive mapping function. (I’ll have to find a quicker transform, as in my tests the switching takes too long. But this could be due to the actually large test image. In addition, I currently only manage to do the backward step by storing the indices in an index matrix.)
> function ii=ma2ve(j,k)
> p=479; q=480; a=p; b=q;
> ii = mod(b*q*j+a*p*k , p*q);
> if ii==0; ii=p*q; end
> endfunction
> ma2ve(1,1)
ans = 1
> ma2ve(1,2)
ans = 229442
> p*q
ans = 229920
I have to return N instead of 0 to have a correct index value. Although the mapping is actually an isomorphism I didn’t know how to go back to the tuple (j,k), so I store the indices in an index matrix while building the image vector:
> idx=zeros(p,q); imv=zeros(1,N);
> tic; for ii=1:p; for jj=1:q;
> idx(ii,jj) = ma2ve(ii,jj);
> imv(idx(ii,jj)) = im(ii,jj);
> end; end; toc
Elapsed time is 58.358711 seconds.
58 seconds!?
> plot(imv)
Continue reading "Images to vectors and back" Friday, March 30. 2007Haft, II![]()
Die Köchin befindet sich in Schmackhaft. Thursday, March 29. 2007Oh no! The eighties are back!![]() ![]()
Posted by Stephan Paukner
in Curiosities
at
15:13
| Comments (0)
| Trackbacks (0)
Defined tags for this entry: fashion
Tuesday, March 27. 2007Raising questions, 70-73![]()
I noticed that I’ll have to find a representation of images as vectors, and not as matrices as usual. Because otherwise I won’t be able to describe linear operations as matrices on vectors. To be able to do things like an SVD or a look at eigenvalues or eigenvectors, I’ll have to evaluate matrices on vectors. For building lattices or Gabor systems I’ll have to try to use the algorithms which have been developed for 1D-signals. This leads me to Gabor Analysis on locally compact abelian groups, but group theory is a little bit away from ordinary signal analysis. Reading first intros, I asked myself:
Posted by Stephan Paukner
in Master's Thesis
at
10:29
| Comments (0)
| Trackback (1)
Defined tags for this entry: mathematics
Sunday, March 18. 2007Schwarzfahren kann sich unmöglich auszahlen![]()
Ich kenne jemanden, der/die darauf spekuliert, dass das regelmäßige Zahlen der Strafen fürs Schwarzfahren in Summe billiger kommt als die Jahreskarte der Wiener Linien. Diese kostet bei Teilzahlung €417/Jahr, und einmal beim Schwarzfahren erwischt werden kostet €60. Damit darf man höchstens sechs Mal im Jahr erwischt werden. Ich bin aber seit Jänner 2007 schon vier Mal kontrolliert worden. Wenn der Trend so weitergeht, bin ich bis Jahresende 16 Mal kontrolliert worden und hätte €960 hingeblättert. Die erstgenannte Spekulation kann also nur funktionieren wenn er/sie nur selten und/oder nur zu “exotischen” Uhrzeiten fährt.
Posted by Stephan Paukner
in Personal
at
13:28
| Comments (0)
| Trackbacks (0)
Defined tags for this entry: german
« previous page
(Page 20 of 55, totaling 435 entries)
» next page
|
AboutCalendarArchivesCategoriesShow tagged entriesandroid antenna anti-spam apache astronomy austria automobile ballooning bash bluetooth bug career cloud comic cooking crypto cw debian diy dreams education electronics fail fashion finance flickr fuerteventura fun gentoo geography german gnu-linux gnucash google google earth guitar hardware history image processing internet kernel kids language lifestyle linkroll literature ltd machine learning making mallorca mathematics matlab microsoft migration movies munich music nautilus numismatics octave pdf perl philately philosophy phone photo gear photography podcast politics postfix private programming public transport rant religion review salzburg samsung science security shtf social web software statistics storage sustainability symbian tablet time lapse transceiver tv usenet venice video virtualization wordplay work www yahoo youtube
Syndicate This BlogFollow meBookmarksPowered by |