Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q1, Activity: Manipulating images: In Pairs (5 marks) (from last workshop). In t

ID: 655806 • Letter: Q

Question

Q1, Activity: Manipulating images: In Pairs (5 marks) (from last workshop). In the same pairs as the last workshop, implement the algorithm that you designed for the following problem: Write a function interleavePictures to interleave two pictures of the same size. For each row, take the first 20 pixels from the first picture (20 pixels wide, 1 pixel high) and then 20 pixels from the second picture (20 pixels wide, 1 pixel high) and then the next 20 pixels from the first picture (20 pixels wide, 1 pixel high) and then the next 20 pixels from the second picture (20 pixels wide, 1 pixel high) and so on till all the pixels from both pictures have been used. The function should return the resulting picture. You will have a chance to work on the code for your algorithm in the next workshop. However, if you have time you can start working on that now. Highly simplified example: consider two pictures where the pixels are all 'a' in the first picture and all 'b' in the second picture. Then the result should look like the following: aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbb ... aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbb ... . . . . . . Note: your algorithm might run into problems if both pictures are not 'multiples of 20 pixels wide'. We leave it up to you to decide how to deal with such inputs.

Explanation / Answer

create object of Image class

function Image interleavePictures(Image pic1,Image pic2)

{

        initialize image class object with twice the size of pic1 or pic2

        define for loop for range 1 to pic1.width with 20 pixel jump

          set RGB for new image with first the RGB of pic1 and RGB of pic2

}

set RGB for new image with the remaining RGB of pic1 and emaining RGB of pic2