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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:20:43+00:00 2026-05-14T06:20:43+00:00

rgbImage = grayImage / max(max(grayImage)); or rgbImage = grayImage / 255; Which of the

  • 0
rgbImage = grayImage / max(max(grayImage));

or

rgbImage = grayImage / 255;

Which of the above is right,and reason?

  • 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-14T06:20:43+00:00Added an answer on May 14, 2026 at 6:20 am

    To convert a grayscale image to an RGB image, there are two issues you have to address:

    • Grayscale images are 2-D, while RGB images are 3-D, so you have to replicate the grayscale image data three times and concatenate the three copies along a third dimension.
    • Image data can be stored in many different data types, so you have to convert them accordingly. When stored as a double data type, the image pixel values should be floating point numbers in the range of 0 to 1. When stored as a uint8 data type, the image pixel values should be integers in the range of 0 to 255. You can check the data type of an image matrix using the function class.

    Here are 3 typical conditions you might encounter:

    • To convert a uint8 or double grayscale image to an RGB image of the same data type, you can use the functions repmat or cat:

      rgbImage = repmat(grayImage,[1 1 3]);
      rgbImage = cat(3,grayImage,grayImage,grayImage);
      
    • To convert a uint8 grayscale image to a double RGB image, you should convert to double first, then scale by 255:

      rgbImage = repmat(double(grayImage)./255,[1 1 3]);
      
    • To convert a double grayscale image to a uint8 RGB image, you should scale by 255 first, then convert to uint8:

      rgbImage = repmat(uint8(255.*grayImage),[1 1 3]);
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of integers which represent a RGB image and would like
I have a greyscale image which was created from a RGB image using farmula:
[r,c,d] = size(rgbImage); %# Get the image dimensions What does r,c,d stand for here?
which algorithm to use to scale down 32Bit RGB IMAGE to custom resolution? Algorithm
I came across this amazing response Applying MATLAB's idwt2 several times which I executed
The image which one can get from OpenNI Image Meta Data is arranged as
I am writing a function Conv2ByFFT() to do the Gaussian blur which is similar
I have a 3D matrix im which represents an RGB image. I can do
I have two images which i would like to compare and do different operations
Or say does 1 denotes white for an RGB image? I have this question

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.