One way to form digital images is through coding. The codes below could be used
ID: 3583017 • Letter: O
Question
One way to form digital images is through coding. The codes below could be used for a digital RGB image.
Var texSize = 64
Var numRows = 8
Var numCols = 8
Var numComponents = 4
Var myImage = new Uint8Array (numComponents*textSize*texSize);
var image1 = new Uint8Array (4*texSize*texSize);
for ( var i = 0; i < texSize; i++) {
for (var j = 0; j <texSize; j++) {
var patchx = Math.floor(i/(texSize/numRows));
var patchy = Math.floor(j/(texSize/numCols));
if (patchx%2^patchy%2) c = 255;
else c = 0;
//c = 255*(((i & 0x8) == 0) ^ ((j & 0x8) == 0))
image1 [4*i*texSize+4*j] = c;
image1 [4*i*texSize+4*j+1] = c;
image1 [4*i*texSuze+4*j+2] = c;
image1 [4*i*texSuze+4*j+3] = 255;
}
}
a) Explain what the first four code lines represent
b) What is the code expected to do?
c) How does geometric pipeline differ from the digital pipeline?
Explanation / Answer
Please Let me know if you need more information:-
--------------------------------------------------------------------------------
a) Explain what the first four code lines represent
b) What is the code expected to do?
c) How does geometric pipeline differ from the digital pipeline?
----------------------------------------
Var texSize = 64 //Declaration of variables for image values calculation.
Var numRows = 8
Var numCols = 8
Var numComponents = 4
Var myImage = new Uint8Array (numComponents*textSize*texSize);
var myInage = new Uint8Array(4*64*64);
var myInage = new Uint8Array(16384);
----> Uint8Array an array of 8-bit unsigned integers.
all values will be initialized to 0. Once array created, you can reference elements in the array using the object's methods, or using bracket notation
--> var image1 = new Uint8Array (4*texSize*texSize); //Same as above declaration
for ( var i = 0; i < texSize; i++) { //Loop repeates for 64 times as texSize =64
for (var j = 0; j <texSize; j++) { //Inner For Loop will also repeats for 64 times.
var patchx = Math.floor(i/(texSize/numRows)); i=0;texSize=64 ; numRows=8
(0/63/8) -- > 0
1/64/8 -->0
......................etc
floor() method rounds a number downwards to the nearest integer, and returns the result
After all calclations:-
image1 [4*i*texSize+4*j] = c;
image1 [4*i*texSize+4*j+1] = c;
image1 [4*i*texSuze+4*j+2] = c;
image1 [4*i*texSuze+4*j+3] = 255;
Making image pixel values into array using the above four lines
geometry pipelin --> is first stage in computer graphics systems which perform image generation based on geometric models.
digital pipeline --> it's latest technology for image generation based on digital models.
Thanks
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.