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. CODE: > 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. CODE: > 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:
CODE: > 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.
(Page 1 of 1, totaling 1 entries)
|
AboutCalendarArchivesCategoriesShow tagged entriesandroid anti-spam apache astronomy austria automobile ballooning bash bug career cloud collecting comic cooking crypto cw debian diy dreams education electronics event fail fashion finance flickr fuerteventura fun gentoo geography german gnu-linux google google earth graphics guitar hardware history image processing internet kernel kids language lanzarote lhc lifestyle linkroll literature ltd machine learning making mathematics matlab microsoft migration movies munich music nautilus numismatics octave pdf perl philosophy phone photo gear photography physics 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
Syndicate This BlogFollow meBookmarks
Powered by |