MATLAB Answers


how to divide a 512*512 image block by pseudo randomly permuting into 8*8 blocks?

Asked by vyshnavi
on 14 Aug 2012

the data hider pseudo-randomly selects Np encrypted pixels that will be used to carry the parameters for data,Np is a small positive integer,for example,Np=20.the other(N-Np) encrypted pixels are pseudo randomly permuted and divided into number of groups,each of which contains L what is the permutation needed and the code used to divide?

  1 Comment

Please review the guide to tags and add tags to this question; see


No tags are associated with this question.


No products are associated with this question.

1 Answer

Answer by the cyclist
on 14 Aug 2012
Edited by the cyclist
on 14 Aug 2012

I thought I understood the title of your post, but I have to admit I did not really understand your question at all. But, maybe this will help a tiny bit. It randomizes the 4,096 blocks of size 8*8 that tile your 512*512 array.

% Pretend data
A = rand(512);
% Random linear index to the blocks
r = randperm(4096)';
% (i,j) subscripts instead of linear index
[i,j] = ind2sub([64 64],r)
% Example of grabbing the 37th randomly found block
whichBlock = 37;
randomBlock = A(8*(i(whichBlock)-1)+(1:8),8*(j(whichBlock)-1)+(1:8))

  1 Comment

on 6 May 2013

Hello Sir, After randomBlock, could you tell me how to show all randomBlock in 512x512array? i followed your codes,and i added loop for example

for whichBlock = 1:64;
randomBlock = A(8*(i(whichBlock)-1)+(1:8),8*(j(whichBlock)-1)+(1:8));

i want random 64block.then, what should i do?

thank you

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!