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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:00:46+00:00 2026-05-23T08:00:46+00:00

I need to convert an unsigned char image (640x480x1) or smaller to a float

  • 0

I need to convert an unsigned char image (640x480x1) or smaller to a float image for processing. I can’t do fixed-point computation in this case due to the problem complexity. I currently use the neon unit in a two-step process. The neon can convert an integer to an float fairly fast, but not an unsigned char to float.

1) convert unsigned char image to integer image using a LUT (no generic casting since I know the range)
2) use the neon to convert from integer to float

This process take roughly 10-15 ms just to prepare the image for processing.

I could also use a LUT in step one that converts directly to a float. However, I have found that doing this takes longer than using the NEON from integer to float. So I’d actually like to use the NEON to convert directly from an unsigned char to float and get rid of step 1.

Does anyone know of a better way?

  • 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-23T08:00:47+00:00Added an answer on May 23, 2026 at 8:00 am
    • If you’re going to use a LUT anyway, just fill it with the necessary floats.
    • If you don’t mind a requirement of iOS 4, see vDSP_vflt8()

    EDIT: “unsigned char to int conversion” merely involves adding some zero bytes at the right places. The obvious way is to perform the necessary shifts, then VDUP to clear a vector, and VMOV.U8 four times. That seems a bit slow.

    The faster way is probably with VTBL:

    ; load stuff into D4 (e.g. {6,7,8,9,a,b,c,d})
    ; D5 already contains {0,-1,-1,-1,1,-1-1-1}
    ; D6 already contains {2,-1,-1,-1,3,-1-1-1}
    ; D7 and D8 are similar...
    vtbl.8 D0,{D4},D5
    vtbl.8 D1,{D4},D6
    vtbl.8 D2,{D4},D7
    vtbl.8 D3,{D4},D8
    ; Now Q0 should contain {6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0}; similarly for Q1
    ; Interpret them as (little-endian) 32-bit ints and convert them to floats
    vcvt.f32.u32 Q0,Q0,#0
    vcvt.f32.u32 Q1,Q1,#0
    ; And save them somewhere
    

    Of course, you can specify #8 instead of #0 to divide everything by 256.

    I didn’t see a quadword version of VTBL, but such a rewrite wouldn’t be too hard to do. The obvious extension is to do a quadword load in to Q2 = {D4,D5}, and repeat the process specifying D4 instead of D5 (or use more registers to avoid data dependency stalls).

    Other optimizations include preloading the cache (I forget what the corresponding ARM instructions are). In general, you’ll probably find it difficult to beat Accelerate.framework without putting in significant effort.

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

Sidebar

Related Questions

I have unsigned char[] that contains binary text. I need to convert this binary
I have a (void*) buffer that I need to convert to std::vector<unsigned char> before
How do I convert a unsigned char buffer to a jbyteArray? I need get
CAST() seems to only work for BINARY,CHAR,DATE;DATETIME,DECIMAL,TIME,SIGNED,UNSIGNED. I need to convert a hex string
I need if possible port this function to c++: static unsigned char bux_code[3] =
I need to convert strings in Python to other types such as unsigned and
I need to convert unicode strings in Python to other types such as unsigned
I need to translate this into Objective-C, can anyone help ? var randomString =
I have a special unsigned long (32 bits) and I need to convert the
I'm using C++ CLI. I need to convert usual char * to cli array.

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.