Ask your own question, for FREE!
Computer Science 71 Online
OpenStudy (he66666):

Help on python: If the function name is "widen", with the parameter "picture" and the return type being a picture, return a new picture that is twice as wide as the given picture. For each pixel (x, y) in the original picture, the pixels (2 * x, y) and (2 * x + 1, y) in the new picture should be set to the same color as it. Can someone please help me? I cant seem to do this. (btw, we cannot use the PIL)

OpenStudy (rsmith6559):

xy coordinates suggest a list of lists as the data structure. For all the color datum in the horizontal, just add it twice to the horizontal of a new list of lists.

OpenStudy (he66666):

Yes I understand that but I don't get how you would set the function. I'm a beginner at Python so I don't know how to set the function properly. I also don't get why in the question 1 is added to 2*x in the x-coordinate?

OpenStudy (rsmith6559):

TBH, ( 2 * x, y ) suggests to me that the image becomes two images side by side. If you just want to distort the image to be twice as wide, reading ( x, y ) from the input picture and writing x to ( x, y ) and ( x +1, y ) in a new image ( to be returned from the function ) will make it twice as wide. The Python syntax for a function would be: def widen( inputPicture ): # make the new picture return( outputPicture ) And would be called something like: fatPicture = widen( thinPicture ) I don't know what else to say without writing the code for you without a more specific question.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!