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 9172687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:24:34+00:00 2026-06-17T16:24:34+00:00

I’ve got an image read into numpy with quite a few pixels in my

  • 0

I’ve got an image read into numpy with quite a few pixels in my resulting array.

I calculated a lookup table with 256 values. Now I want to do the following:

for i in image.rows:
    for j in image.cols:
        mapped_image[i,j] = lut[image[i,j]]

Yep, that’s basically what a lut does.
Only problem is: I want to do it efficient and calling that loop in python will have me waiting for some seconds for it to finish.

I know of numpy.vectorize(), it’s simply a convenience function that calls the same python code.

  • 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-06-17T16:24:35+00:00Added an answer on June 17, 2026 at 4:24 pm

    You can just use image to index into lut if lut is 1D.
    Here’s a starter on indexing in NumPy:
    http://www.scipy.org/Tentative_NumPy_Tutorial#head-864862d3f2bb4c32f04260fac61eb4ef34788c4c

    In [54]: lut = np.arange(10) * 10
    
    In [55]: img = np.random.randint(0,9,size=(3,3))
    
    In [56]: lut
    Out[56]: array([ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90])
    
    In [57]: img
    Out[57]: 
    array([[2, 2, 4],
           [1, 3, 0],
           [4, 3, 1]])
    
    In [58]: lut[img]
    Out[58]: 
    array([[20, 20, 40],
           [10, 30,  0],
           [40, 30, 10]])
    

    Mind also the indexing starts at 0

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

Sidebar

Related Questions

I got this SVG image from Wikipedia and embedded it into a website using
I was reading from a few tutorials on how to upload my image into
I've got raw data streams from image files, like: vector<char> rawData(fileSize); ifstream inFile(image.jpg); inFile.read(&rawData[0]);
I got a image like below with padding-right: 15px <td><img style=padding:0px 15px 0px 0px;...
I've got an image that's allowed to be rotated and scaled by the user.
I've got this image: I want to code this image (just the bar, not
I'm facing a problem of algorithm. Here's the thing : I've got an image
Alright.. I'm struggling with this one.. I've got an image with a transparent hole
I´ve got a star image as <img> . This image has a javascript function,
I've got a background image that changes to another image when :hover. I used

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.