A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

he66666

  • 4 years ago

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)

  • This Question is Closed
  1. rsmith6559
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  2. he66666
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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?

  3. rsmith6559
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.