Similar Threads

1. Shuffling imaginary compenents of an image

Hi!
I'm a bit stuck on code and i was hoping for some help, I'm writing a simple script (at least it was meant tobe simple!) to shuffle the imaginary components of an image and then reconstruct it. The problem at the moment is that when i ifft2 the image it doesn't look as expected (a layer of the image seems to be inverted and that's it). I think i need to apply the same shuffle to each quadrant of the fourier image but as i'm a bit new to matlab i'm not sure how to do this. Any help would be welcomed
Best
Josh
%% script so far
I = imread('orig_pic.jpg');
F = fftshift(fft2(I));
shuffle_pic = shuffle(imag(F)); %here i'm using a shuffle code i found on the web
J = complex(real(F),shuffle_pic);
K = ifft2(J);
subplot(1,2,1), image(J), title('orig image);
subplot(1,2,2),image(K), title('shuffle image');
%%shuffle function
function x = shuffle(x)
%SHUFFLE Shuffle an array of values.
% x = shuffle(x) shuffles the vector x in random order.
% Since this function changes the vector x,
% it creates a copy of it.
n = size(x);
m = n(1)*n(2)*n(3);
for index = 1:m
% a random number between i and n
r = index + floor((m-index+1) * rand());
% swap elements index and r
x([index r]) = x([r index]);
end

2. shuffle a matrix? - MATLAB

3. randomly shuffled vector

Hi,
I have a vector of very long length (more than 100,000). Is there a
quick way to randomly shuffled all of the elements in the vector. Thank you
very much.
Jesse J.

4. Shuffling a Matrix - MATLAB

5. A fun puzzle: the prefect shuffle

The object of the puzzle is to come up with the shortest expression
that does a perfect shuffle on a vector.
So, if the given vector is x wokout the shortest algorithm to implement
ps(), where:
>> x = [1:5 10:10:50];
>> ps(x) % the perfect shuffle
ans =
1 10 2 20 3 30 4 40 5 50
The length of x can of course be odd.
/reza.

6. Shuffled Autocorrelation?? - MATLAB

7. Shuffle matrices

"Brett Shoelson" < XXXX@XXXXX.COM > wrote in
news:w%Dac.12$ XXXX@XXXXX.COM :
>
> "Equinox1248" < XXXX@XXXXX.COM > wrote in message
> news: XXXX@XXXXX.COM ...
>> Is there a simple way to shuffle the matrices without going through
>> for loops? What I want to do is as follows
>>
>> example:
>> x = [1 2
>> 3 4]
>>
>> y = [5 6
>> 7 8]
>>
>> z = [ 1 2
>> 5 6
>> 3 4
>> 7 8]
>>
>> thank you in advance
>
> Interesting little problem with many solutions...
> The easiest, I think, is to first construct a single matrix, then
> alternate the indices:
>
>>> z = [x;y];
>>> z = [z(1:2:end,:);z(2:2:end,:)]
>
> z =
>
> 1 2
> 5 6
> 3 4
> 7 8
>
> Cheers,
> Brett
>
>
Indeed an interesting little problem. Another solution:
z = reshape([x' ; y'],2,4)' ;
Jos
--
Email: jnvdg AT arcor DOT de

8. MatLab 7 shuffle command - MATLAB