Specs of input image: HEIGHT == 400, WIDTH == 600 IIIE EI (a) Original Image (b)
ID: 3601262 • Letter: S
Question
Specs of input image: HEIGHT == 400, WIDTH == 600
IIIE EI (a) Original Image (b) Shuffled Image Figure 5: An image and its shuffled counterpart. Shuffling works this way: Divide the image into 16 equally sized image blocks. Then randomly choose a pair of image blocks and swap it's R, G and B values. Repeat choosing and swapping process until all image blocks are swapped. Note that on each run, shuffle should produce a different image. You need to define and implement the following function to do this DIP /Shuffle an image *,/ void Shuffle (unsigned char R[WIDTH] [HEIGHT], unsigned char G[WIDTH] [HEIGHT], unsigned char B[WIDTH] [HEIGHT])Explanation / Answer
<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--
var ShufImgPath='http://www.vicsjavascripts.org.uk/StdImages/';
var ShufImgAry=new Array('One.gif','Two.gif','Three.gif','Tick1.gif','Four.gif','Five.gif');
var ShufRandomNu;
var ShufImgCnt=1;
function ShufImages(){
while (ShufImgCnt<=ShufImgAry.length){
ShufRandomNu=Math.floor(Math.random()*(ShufImgAry.length));
if (ShufImgAry[ShufRandomNu]!='X'){
document.getElementById('ShufI'+ShufImgCnt).src=ShufImgPath+ShufImgAry[ShufRandomNu];
ShufImgAry[ShufRandomNu]='X';
ShufImgCnt++;
}
}
}
//-->
</script>
</head>
<body >
<center>
<table width="600" border="1">
<tr>
<td>
<img id="ShufI1" src="http://www.vicsjavascripts.org.uk/StdImages/Blank.gif" width="100" height="100">
</td>
<td>
<img id="ShufI2" src="http://www.vicsjavascripts.org.uk/StdImages/Blank.gif" width="100" height="100">
</td>
<td>
<img id="ShufI3" src="http://www.vicsjavascripts.org.uk/StdImages/Blank.gif" width="100" height="100">
</td>
<td>
<img id="ShufI4" src="http://www.vicsjavascripts.org.uk/StdImages/Blank.gif" width="100" height="100">
</td>
<td>
<img id="ShufI5" src="http://www.vicsjavascripts.org.uk/StdImages/Blank.gif" width="100" height="100">
</td>
<td>
<img id="ShufI6" src="http://www.vicsjavascripts.org.uk/StdImages/Blank.gif" width="100" height="100">
</td>
</tr>
</table>
</center>
<img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" width="100" height="100">
<br>
<table width="600" height="400" border="1">
<tr>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>.</td>
<td>.</td>
</tr>
</table>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.