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