So, I was tasked with job where I will write a C# application that will go through an image and list out the color of each pixel. Problem is, I'm not really sure what standard the color needs to be. The spec says:

'px (a value in the result set)' shall be the pixel color at a specific spot of the image. The pixel color shall be between 0-255, inclusive.

Later in the spec, it gives an "example of a 3x5 image," then proceeds to display 3 rows of 5 single numbers between 0 and 255.

Obviously it isn't asking for the Hex or CMYK values. It seems like it could be asking for the RGB, but it really seems like it's asking for a SINGLE integer value between 0-255 that fully identifies the color of a particular pixel.

Does such a standard exist?

This is an excerpt FROM the spec:

Here is an example of a 3x5 image file, “babydrawing.img”.

255, 6, 65, 78, 99

100, 25, 0, 45, 66

88, 190, 88, 76, 50

  • 1
    Oh seems nobody did this: Hello and wellcome to GD.SE. We are glad to hace you here.
    – joojaa
    Commented Feb 25, 2015 at 8:20
  • 1
    It is plausible that your function will be receiving an individual color channel. Are there any related functions which, say take a filename or stream, and return an n-dimensional array where n=number of channels? This seems unlikely given the description, but...
    – Yorik
    Commented Feb 25, 2015 at 15:51
  • 1
    We can't answer this. You need to go back to whoever wrote the spec and ask them what they meant. The theory that it's perhaps referring only to black and white images is a good theory, but we can't say for sure, obviously, as we didn't write the spec.
    – DA01
    Commented Feb 25, 2015 at 17:11
  • Maybe you can point to the whole spec somehow
    – joojaa
    Commented Feb 26, 2015 at 5:35

2 Answers 2


1 byte length integers are pretty normal for images, you can say its standard. Hexadecimal is just same thing with different notation (ff=255, 00=0)

1 component per pixel is also not terribly rare, its a grayscale image or any of many other things such as alpha.

  • I had also thought about that, too... that it could be the alpha channel in a grayscale bmp. But, one would think the spec might MENTION THAT!!! lol
    – Christine
    Commented Feb 25, 2015 at 14:58
  • @hill: RGB is really just three greyscale images with the implicit understanding that each will be rendered using a color filter. To complicate things, some alpha is stored as 0-127 and "stretched" to 0-255 on decode :(
    – Yorik
    Commented Feb 25, 2015 at 15:47

I can understand the confusion, when normally one expects, for RGB a three (or four) byte number 0xRRGGBB, when RR, GG and BB range from 0x00 to 0xFF. You may think that RGB8 is a similar standard with just 2 bits per Red, Green and Blue (and a 2 bit alpha channel). But no¹...

From the sounds of it, the image is a bitmap² and is using an 8 bit colour map, or 8bpp, so there are 256 distinct colours supported.

Each byte represents one pixel³ and is an index to a table containing 256 colours. This table is held in memory, and may contain either user defined or a standard system defined set of colours, known as a colour palette.

The actual colours in this colour palette are not set in stone. There is no actual standard, apart from a standard relating to a particular OS. It is possible to change the colours in the colour palette, so that the colours to which the indices refer change, so called colour palette animation and can be used to create some rather psychedelic effects.

The values can indeed represent an increasing greyscale, but in this case the OP states that each number represents a colour and not a shade of grey. In which case, it is using a colour palette.

So, in short, an answer to the OP's question is that there is no set colour for each pixel, the C# program merely has to obtain the colour index for each pixel. The actual colour that the index represents is irrelevant, until the colour palette has been defined.

I hope that makes sense.

As an historical aside, not so long ago (mid 80s), 8 bit video cards were once at the top end of the technology, current at that time. Then along came 16 bit colour (thousands of colours) in the early 90s, then 24 bit colour (millions of colours), in the mid 90s (Apple Quadra Series) and now 32 bit is de rigeur.

¹ Although there are exceptions (3 bits for R and G and 2 bits for B), credit goes to joojaa for the tip.

² There are a number of bitmap formats: BMP (Windows); XPM (X Windows); TIFF and; PPM to name just a few. See Bitmap image file extension list.

³ It might be worth also having a look at the Wikipedia entry for Pixel Format.

  • 1
    I agree that sounds like a 8 bit image. And I would emphasise that you need to define a colour table or use the standard OS colour table. The problem is that I can not find a "standard" colour table. I leave here an example otake.com.mx/Foros/ColorTable-SystemWin.png but some colour tables uses the first row for vga colors. See if you can define this colour table somewhere.
    – Rafael
    Commented Feb 25, 2015 at 10:55
  • I rejected this option because thd spec does not say it is an INDEX but color which would indicate its a value level. However the question is wague so hard to say your as likely to be right as anybody.
    – joojaa
    Commented Feb 25, 2015 at 13:53
  • I agree that the question is rather vague. However, I am not aware of an absolute 8 bit colour scheme, apart from the use of colour palettes. There may be a method, but I don't know it. TBH, I thought that the question was referring to a grey scale initially... :-) Commented Feb 25, 2015 at 13:57
  • Well PDF, postscript, and old unix formats have such schemes
    – joojaa
    Commented Feb 25, 2015 at 14:15
  • 2
    Thanks for all the answers. One person suggested the 5 values in the example row represented the RGB X and Y channels. Which, I don't know what the X and Y channels are, and that doesn't seem to fit in with the whole "Here's a 3x5 image represented by a 3x5 chart of values" thing. I had also thought it was an average of the RGB values, but that also doesn't make sense because the spec also calls for each value being an integer, so they would have to be whole numbers. I'm trying to push back for clarification, but I will also explore the 8 bit color map possibility.
    – Christine
    Commented Feb 25, 2015 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.