Tuesday, April 3. 2007Images to vectors and backRegarding 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 and where . One explicit mapping from the matrix indices to the corresponding vector indices is given by where α and β are integers chosen such that
.
My 480×480 zebra-image doesn’t have a height and width that are relatively prime, so I simply drop one pixel of height:
CODE: > 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.)
CODE: > 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:
CODE: > 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!? However, the image looks like this as a vector:
CODE: > plot(imv)
Continue reading "Images to vectors and back"
(Page 1 of 1, totaling 1 entries)
|
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 meBookmarks
Powered by |