reordering a matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
hai every body i am doing a project for image hiding
where i am dividing the images both host and secret into blocks and sort the blocks based on the average standard deviation value of the blocks
for sorting the blocks i have used the following syntax
[value,index]=sort(avgtar) %avgtar- average standard deviation of all the blocks in the host image
22.9373 30.8103 37.9581 37.4260
25.2341 34.7779 40.5795 52.2461
32.9759 49.8769 42.8880 56.2237
50.3640 53.9688 52.8147 59.7235
index
2 1 1 1
1 2 2 3
3 3 3 4
4 4 4 2
[values,indexs]=sort(avgsec) %avgsec- average standard deviation of all the blocks in the secret image
values
19.5623 22.4814 18.9131 15.8497
25.1652 29.2180 26.4766 22.5056
25.6204 32.9959 30.0659 23.5101
42.7828 34.7110 32.5074 28.6728
indexs
3 4 4 1
4 3 3 4
1 2 2 3
2 1 1 2
now i have to map the blocks in host image to the blocks in secret image in one to one manner
and then reorder the mapping according to the indices of the secret image blocks
i don't know how to map and reorder please help me
0 comentarios
Respuestas (1)
Laurens Bakker
el 7 de Mzo. de 2012
Hi Ramya,
First, you re-order the known image according to the sorted order column by column:
for i=1:size(avgtar,2)
avgtar(:,i) = avgtar( index(:,i) , i );
end
now you need to reverse the ordering, but according to the sorted order of the secret image. Again do this column by column:
for i=1:size(avgsec,2)
avgtar( indexs(:,i), i ) = avgtar(:,i);
end
The tricky bit is the un-doing of the sort of the secret image, which is done in the second for loop I described.
Of course you can easily merge the two for loops:
for i=1:size(avgtar,2)
avgtar( indexs(:,i), i ) = avgtar( index(:,i) , i );
end
But I thought it would be easier to explain the process step by step.
Cheers,
Laurens
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!