Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6653431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:16:07+00:00 2026-05-26T01:16:07+00:00

I have read an image in python using Image module and converted it into

  • 0

I have read an image in python using Image module and converted it into a numpy array as follows…

       im=Image.open(infile)

       imdata = scipy.misc.fromimage(im)

After processing, what I get are not the integer coordinates but the real values. It is important to note that it is an rgb image. I want to get the color value as a bilinearly interpolated value. There is a method in image

     im.getPixel(x,y)

I am not sure that if we can give the real values as coordinates.

If we do it in numpy array, we can do bilinear interpolation but it will be separate for every channel if I am correct???

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:16:07+00:00Added an answer on May 26, 2026 at 1:16 am

    You are correct that getPixel will only accept integer coordinates.

    You can do your own linear interpolation if you don’t mind it being slow:

    def lerp(a, b, coord):
        if isinstance(a, tuple):
            return tuple([lerp(c, d, coord) for c,d in zip(a,b)])
        ratio = coord - math.floor(coord)
        return int(round(a * (1.0-ratio) + b * ratio))
    
    def bilinear(im, x, y):
        x1, y1 = int(floor(x)), int(floor(y))
        x2, y2 = x1+1, y1+1
        left = lerp(im.getpixel((x1, y1)), im.getpixel((x1, y2)), y)
        right = lerp(im.getpixel((x2, y1)), im.getpixel((x2, y2)), y)
        return lerp(left, right, x)
    

    A robust implementation of bilinear would also include bounds checking for when the coordinates go off the image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read an image in python using Image module and converted it into
I have a FAT12 image file and I have to open it and read
How do I read an image in C so that I can have direct
I am having problems with django forms and image uploads. I have googled, read
I have read that using database keys in a URL is a bad thing
I have a small python cgi script that accepts an image upload from the
I have read the following tutorial Uploading Files To the Server Using PHP and
As I have read so far, it seems that the header image of a
I am trying to teach myself digital image process. I have read my pgm
I've been doing some simple web programming using python, and I have a basic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.