If you run a randperm on an array, then a second time on a second array of the same dimensions, will both be shuffled in the same way?

1 visualización (últimos 30 días)
I have a program where a microscope image is shuffled using randperm, but I have images at two different wavelengths at the same time and want to shuffle both in the same way. If I use randperm on a, say, 300x400 image and then rerun the program on another 300x400 image, does randperm do the same operation and shuffle both in the same way, or does it change? If it does change, how might I be sure both were shuffled the same?

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Feb. de 2016
randperm uses the default random number generator. If you have set up the same random number generator seed and ask for the same number of output values then they will be the same. If you do not set up the same random seed then the outputs will seldom be the same.
randperm() does not shuffle images; randperm can be used to generate indices that can be used to shuffle images. You can record the generated order before shuffling the first image and use that recorded order to shuffle the second.
  3 comentarios
Steven Lord
Steven Lord el 10 de Feb. de 2016
shuffledIndices = randperm(sqrelements);
imgVector = imgVector(shuffledIndices);
imgVector2 = imgVector2(shuffledIndices);
Walter Roberson
Walter Roberson el 10 de Feb. de 2016
randorder = randperm(sqrelements);
imgVector=imgVector(randorder);
othervector = othervector(randorder);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by