I have three RGB values,i want to know color of this RGB values,how can i do this

20 views (last 30 days)
Currently i am not able to make this code sorry.......But i just want to know the color of RGB values
My valyes are..
R = 239;
G = 189;
B = 87;
I want to know the Color of this RGB values please anyone can help me ...
My RGB values are continusly changed depend upon that color Image..
  2 Comments
Jonas
Jonas on 30 Nov 2022
Edited: Jonas on 30 Nov 2022
you "want to know the color"
you mean you want a description with text?, e.g. input [255,0,0], output 'red'?
you could define some reference points and describe the colors yourself. After that, you could choose the predefined color names based on the minimum distance to any given RGB value
you could use already existing table data for such a task if you dont want to do this yourself, see e.g. here

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 30 Nov 2022
You could make up an image with only those color values and show it
rows = 30;
columns = 40;
R = 239 * ones(rows, columns, 'uint8');
G = 189 * ones(rows, columns, 'uint8');
B = 87 * ones(rows, columns, 'uint8');
rgbImage = cat(3, R, G, B);
imshow(rgbImage);
  5 Comments
DGM
DGM on 1 Dec 2022
Edited: DGM on 1 Dec 2022
If you want to know the color name, did you try colornames() as I suggested?

Sign in to comment.

More Answers (1)

DGM
DGM on 1 Dec 2022
Edited: DGM on 16 Mar 2023
I have no idea what's going on here either, but I can guess.
If you want a color name, then you can use Stephen's colornames() tool. Of course, if you want a named color, you'll have to specify the context within which it's defined (i.e. the palette).
R = 239;
G = 189;
B = 87;
mytuple = [R G B]/255 % unit-scale double
palettes = colornames(); % a list of all available palettes
matchname = cell(numel(palettes),1);
swatchchart = zeros(numel(palettes),2,3);
for p = 1:numel(palettes)
[matchname(p) matchtuple] = colornames(palettes{p},mytuple);
swatchchart(p,1,:) = mytuple;
swatchchart(p,2,:) = matchtuple;
end
% the closest match within each palette
[palettes matchname]
ans =
30×2 cell array
{'Alphabet' } {'Orpiment' }
{'AmstradCPC' } {'15 Orange' }
{'AppleII' } {'13 Yellow' }
{'Bang' } {'79 Light Brilliant Gamboge'}
{'BS381C' } {'353 Deep Cream' }
{'CGA' } {'14 Yellow' }
{'Crayola' } {'Mango' }
{'CSS' } {'Goldenrod' }
{'dvips' } {'Dandelion' }
{'Foster' } {'Butterscotch' }
{'HTML4' } {'Yellow' }
{'ISCC' } {'67 Brilliant Orange Yellow'}
{'Kelly' } {'3 Yellow' }
{'MacBeth' } {'12 Orange Yellow' }
{'MATLAB' } {'Yellow' }
{'Natural' } {'Yellow' }
{'R' } {'Goldenrod2' }
{'RAL' } {'1012 Lemon Yellow' }
{'Resene' } {'Ronchi' }
{'Resistor' } {'-1 Gold' }
{'SherwinWilliams'} {'6676 Butterfield' }
{'SVG' } {'Goldenrod' }
{'Tableau' } {'9 Olive' }
{'Thesaurus' } {'Yellow: Mustard' }
{'Trubetskoy' } {'3 Yellow' }
{'Wikipedia' } {'Maximum Yellow Red' }
{'Wolfram' } {'Orange' }
{'X11' } {'Goldenrod2' }
{'xcolor' } {'Brown' }
{'xkcd' } {'Macaroni And Cheese' }
% compare the matches (left) to the original color (right)
imshow(swatchchart)
If you want to refine the results, you can.
% calculate the color distance between each
DE = imcolordiff(swatchchart(:,1,:),swatchchart(:,2,:));
% get rid of anything that has an excessive distance
goodmatches = DE<6; % pick some distance
palettes = palettes(goodmatches);
matchname = matchname(goodmatches);
swatchchart = swatchchart(repmat(goodmatches,[1 2 3]));
swatchchart = reshape(swatchchart,[],2,3);
% the closest match within each palette
[palettes matchname]
ans =
11×2 cell array
{'Bang' } {'79 Light Brilliant Gamboge'}
{'BS381C' } {'353 Deep Cream' }
{'Foster' } {'Butterscotch' }
{'ISCC' } {'67 Brilliant Orange Yellow'}
{'R' } {'Goldenrod2' }
{'Resene' } {'Ronchi' }
{'SherwinWilliams'} {'6676 Butterfield' }
{'Thesaurus' } {'Yellow: Mustard' }
{'Wikipedia' } {'Maximum Yellow Red' }
{'X11' } {'Goldenrod2' }
{'xkcd' } {'Macaroni And Cheese' }
% compare the matches (left) to the original color (right)
imshow(swatchchart)
Then again, you've asked both for the color of RGB values, and for RGB values of a color image. So I can't even know which is the known and which is the unknown.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!