Questions tagged [rgb]

RGB stands for Red-Green-Blue and specifies a color using three values, which represent the respective amount of red, green, and blue in the color. RGB is the basis for the color model used by most color display devices nowadays.

The RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue. RGB is a color notation used in most computing devices nowadays.

RGB colors are represented by a tuple of three values (one per primary color), which are typically either bytes ranging from 0 to 255 or floating-point values ranging from 0.0 to 1.0.

3547 questions
33
votes
5 answers

Generating gradients programmatically?

Given 2 rgb colors and a rectangular area, I'd like to generate a basic linear gradient between the colors. I've done a quick search and the only thing I've been able to find is this blog entry, but the example code seems to be missing, or at least…
Paul Wicks
  • 62,960
  • 55
  • 119
  • 146
33
votes
3 answers

How can I read image pixels' values as RGB into 2d array?

I was making a 2d map editor for my square tile platformer game, when I realized I could really use an image editor with its abilities to repaint adjacent pixels and many more, so I figured I should try and read a painted level by an app that will…
user1306322
  • 8,561
  • 18
  • 61
  • 122
32
votes
8 answers

Compare RGB colors in c#

I'm trying to find a way to compare two colors to find out how much they are alike. I can't seem to find any resources about the subject so I'm hoping to get some pointers here. Idealy, I would like to get a score that tells how much they are alike.…
SaphuA
  • 3,092
  • 3
  • 39
  • 58
32
votes
4 answers

ImageIO reading slightly different RGB values than other methods

I've found that I'm getting different RGB when using Java (& actually paint.NET) than I am using ImageMagick, Gimp, Python, and Octave. The last 4 all agreeing with eachother and so I'm assuming to be correct. For these examples, I'm using this test…
matt burns
  • 24,742
  • 13
  • 105
  • 107
32
votes
6 answers

Calculate RGB value for a range of values to create heat map

I am trying to create a heat map with python. For this I have to assign an RGB value to every value in the range of possible values. I thought of changing the color from blue (minimal value) over green to red (maximal value). The picture example…
aldorado
  • 4,394
  • 10
  • 35
  • 46
31
votes
6 answers

Extract black and white image from android camera's NV21 format

I have done some google-ing around and couldn't find enough information about this format. It is the default format for camera preview. Can anyone suggest good sources of information about it and how to extract data from a photo/preview image with…
Ethan
  • 1,488
  • 3
  • 19
  • 24
31
votes
4 answers

How is a convolution calculated on an image with three (RGB) channels?

Say we have a single channel image (5x5) A = [ 1 2 3 4 5 6 7 8 9 2 1 4 5 6 3 4 5 6 7 4 3 4 5 6 2 ] And a filter K (2x2) K = [ 1 1 1 1 ] An example of applying convolution (let us take the first 2x2 from A) would…
Aragorn
  • 477
  • 1
  • 8
  • 12
31
votes
5 answers

How can I obtain a CGColor from RGB values?

I am trying to create a custom RGB CGColor using Swift to use as a border color for a UIButton. I've tried following code but the color is not visible: var red = UIColor(red: 100.0, green: 130.0, blue: 230.0, alpha: 1.0) self.layer.borderColor =…
alionthego
  • 8,508
  • 9
  • 52
  • 125
30
votes
4 answers

how to convert hexadecimal to RGB

I want to make a conversion from hexadecimal to RGB, but the hexadecimal deal with a string like #FFFFFF. How can I do that?
R. Dewi
  • 4,141
  • 9
  • 41
  • 66
30
votes
3 answers

How do you get random RGB in Javascript?

I have this code that uses RGB color selection and I was wondering how to make JavaScript do a random color using the RGB method and remember it throughout the code. EDIT: I tried this: var RGBColor1 = (Math.round, Math.random, 255) var RGBColor2 =…
ipodlover3354
  • 449
  • 1
  • 4
  • 11
30
votes
9 answers

Convert rgb strings to hex in Javascript

I am using the TweenMax JS library with the ColorPropsPlugin which will tween color values which are specified in many formats, the problem I have is that the result is always in the form of a string: "rgb(255,255,255)" How can that be converted in…
Neil
  • 7,861
  • 4
  • 53
  • 74
29
votes
5 answers

Algorithm for finding the color between two others - in the colorspace of painted colors

When mixing blue and yellow paint, the result is some sort of green. I have two rgb colors: blue = (0, 0, 255) and yellow = (255, 255, 0) What is the algorithm for finding the rgb color that is the result of mixing the two colors, as they would…
Alexander
  • 9,737
  • 4
  • 53
  • 59
29
votes
11 answers

Programmatically choose high-contrast colors

This should be a simple question, but I haven't been able to find a way to make it work. Essentially, I have a silly localhost page that I use in my webdevelopment. When I am surfing between our development server and my local version of the C#…
Jeff
  • 2,835
  • 3
  • 41
  • 69
28
votes
8 answers

Star B-V color index to apparent RGB color

I'm trying to convert a star's B-V color index to an apparent RGB color. Besides look up tables and color ramps, it seems like there's no well known algorithm for doing this. What's a B-V color index? It's a number astronomers assign to a star to…
melhosseiny
  • 9,992
  • 6
  • 31
  • 48
27
votes
6 answers

Convert grayscale value to RGB representation?

How can I convert a grayscale value (0-255) to an RGB value/representation? It is for using in an SVG image, which doesn't seem to come with a grayscale support, only RGB... Note: this is not RGB -> grayscale, which is already answered in another…
Rabarberski
  • 23,854
  • 21
  • 74
  • 96