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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:18:16+00:00 2026-05-16T14:18:16+00:00

I have an application that receives a pointer to JPEG data from a camera

  • 0

I have an application that receives a pointer to JPEG data from a camera API wrapped with ctypes, converts it to a wx.Image, and displays the images as a movie.

One of required features is to set two of the components of a pixel equal to the third. E.g, my pixel in RGB format is (100,200,255), I want to set the the R and B values equal to the G, or (200,200,200). I need to do t
his for every pixel in the image whilst maintaining a decent framerate.

I can access the RGB values from my wx.Image by calling the Image.GetData, which returns a string containing the pixel values in the following format: RGBRGBRGB … I have implemented the feature naively by iterating through this RGBRGBRGB string.

However, this naive approach is far too slow to achieve a decent FPS because (I think):

a) I am iterating through every pixel in the image.

b) I am doing too much data copying.

I have considered converting my RGB data to numpy, performing the operation (I assume numpy would have a faster way of doing this sort of thing), and then converting back to wx.Image. Unfortunately I cannot convert straight from the raw data to numpy as the data comes as a JPEG, not in as a RGB bitmap. So I would need to go from data->wx.Image->numpy array->wx.Image.

I have also considered implementing my own python buffer which will return, for example, the G pixel value instead of the R and B values when being read. I think this would be the ideal solution, as it requires no data copying or excessive iterations, but I have no idea how to go about doing this. Will I need to write this buffer in C? Is it possible to implement buffers in pure python and still manipulate raw memory?

So SO, how do you think I should go about improving my performance? Should I attempt the numpy or buffer solution, or is there an easier solution that I am missing?

I am mainly looking for ideas/links to relevant documentation or examples, but if someones wants to write some code then that’s fine 🙂

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-16T14:18:17+00:00Added an answer on May 16, 2026 at 2:18 pm

    You could try using the Python Imaging Library (PIL) – this is a library for manipulating images.

    You can find information about converting between a wxPython image and a PIL image here, or you can load the jpeg directly into a PIL image.

    Once you have converted your wx image into a PIL image I think this will do what you want (but I have not tested it):

    r, g, b = im.split()              # split the image into separate color planes
    im = Image.merge("RGB", (g, g, g))  # merge them back, using the green plane for each
    

    Then convert it back to a wxPython image.

    This should be orders of magnitude faster than doing it in Python, since PIL is implemented in C and optimised for image processing.

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

Sidebar

Related Questions

I have a Delphi 6 application that receives and processes an image stream from
I have an application that sends and receives data from another application running on
I have a server application that receives some special TCP packet from a client
I have an application that receives messages from devices every few minutes. I also
I have an application which receives GPS data from a mobile device as well
I have an application that receives information from a database, and is used to
I have an application that receives messages from server. Those messages may contain cyrillic
Currently I have an application that receives an uploaded file from my web application.
I have an application that receives a number of datums that characterize 3 dimensional
I have a combobox in a view that receives information about application state changes,

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.