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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:18:21+00:00 2026-05-22T00:18:21+00:00

I need to uniformly re-quantize the dynamic range of an image based on the

  • 0

I need to uniformly re-quantize the dynamic range of an image based on the following pixel value conversions:

Pixel Value: Quantized Value
0 - 64     : 31
65 - 128   : 95
129 - 192  : 159
193 - 255  : 223

I want to replace all the pixel values in the above ranges with the quantized values. How can I code this in MATLAB?

  • 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-22T00:18:22+00:00Added an answer on May 22, 2026 at 12:18 am

    One way is to use logical indexing. Given a image matrix img (which could be 2-D grayscale or 3-D RGB), this will replace all your values:

    img(img >= 0 & img <= 64) = 31;
    img(img >= 65 & img <= 128) = 95;
    img(img >= 129 & img <= 192) = 159;
    img(img >= 193 & img <= 255) = 223;
    

    Another option is to create a 256-element look-up table and use the values in your image as indices into this table:

    lookupTable = [31.*ones(1,65) 95.*ones(1,64) 159.*ones(1,64) 223.*ones(1,63)];
    img = uint8(lookupTable(double(img)+1));
    

    Note that with this solution you will have to be mindful of the class of your image matrix. Many images are of class uint8, spanning values 0 to 255. To use these values as an index you have to convert them to a class that can store larger integers (like double) to avoid saturation at the maximum value of 255, then add one since you need an index from 1 to 256. You would then want to convert the resulting image matrix back to class uint8.

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

Sidebar

Related Questions

Need to locate the following pattern: The letter I followed by a space then
Need to call a filter function on some options based on a radio selected
I am faced with the following programming problem. I need to generate n (a,
A brief background: I'm working on a web-based drawing application and need to draw
I need to generate arbitrarily large random integers in the range 0 (inclusive) to
My problem is the following: I need to generate lot of random numbers in
I need to sample uniformly at random a number from a set with fixed
I need to place three elements inside RelativeLayout : scaled image in ImageView on
Stepping back from the following question : Selecting with Cases I need to generate
Need a function that takes a character as a parameter and returns true if

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.