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

  • Home
  • SEARCH
  • 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 4095012
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:49:48+00:00 2026-05-20T19:49:48+00:00

I want to convert images to web-safe colors using MATLAB. Is there any predefined

  • 0

I want to convert images to web-safe colors using MATLAB. Is there any predefined function for it? If not, what should be my first step to start off?

  • 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-20T19:49:49+00:00Added an answer on May 20, 2026 at 7:49 pm

    Ashish has the right approach, but you may be finding it daunting to get all those values off of the web page and into a map that you can use. You have a couple of options for creating the map…

    One option is to actually get the source for the page using the function URLREAD and parse out the numbers you need using the function REGEXP (“Did he just suggest parsing HTML with a regex?!” Yes, I did. What can I say? I’m a loner, Dottie. A rebel.):

    mapURL = 'http://en.wikipedia.org/wiki/Web_colors#Web-safe_colors';
    urlText = urlread(mapURL);
    matchExpr = ['<td style="background: #\w{3};">' ...
                 '(?:<u>\*)?(\w{3})(?:\*</u>)?</td>'];
    colorID = regexp(urlText,matchExpr,'tokens');
    colorID = char([colorID{:}]);
    [~,webSafeMap] = ismember(colorID,'0369CF');
    webSafeMap = (webSafeMap-1)./5;
    

    However, after I did the above I realized that there is a nice regular structure to the resulting web-safe color map values. This means you could actually ignore all the above mess and generate the map yourself using the functions REPMAT and KRON:

    colorValues = (0:0.2:1).';  %'
    webSafeMap = [repmat(colorValues,36,1) ...
                  kron(colorValues,ones(36,1)) ...
                  repmat(kron(colorValues,ones(6,1)),6,1)];
    

    And then you can easily recolor, say, an RGB image using the functions RGB2IND and IND2RGB. For example:

    imageRGB = imread('peppers.png');  %# Load a built-in image
    imageRGB = ind2rgb(rgb2ind(imageRGB,webSafeMap),webSafeMap);
    imshow(imageRGB);
    

    A web-safe version of peppers.png

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

Sidebar

Related Questions

I want to convert some base64 encoded png images to jpg using python. I
I'm using paperclip to allow user to upload images and I want to convert
I have a folder containing over 200 raw images, i want to convert all
İn Matlab, I want to threshold a grayscale image to convert it to a
I want to save image from chart graphic. I'm using following line. chart.SaveImage(D:\\mypic.png, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png);
I want to convert SVG images to PNG files with transparent background and anti-aliased
I want to convert ppt to images on the client machine and zip all
Is there any way to crop a photo using client side JavaScript only? When
i want convert image into byte array in php.actually i am accessing web service
I have an image in a web page. I want to convert the four-sided

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.