From: Matthew Bennett on
Hi all,

I have managed to get the Y'UV data from an image and superimposed the UV onto a grey image (128,U,V). The problem here is that I now have a large number of values stored as an image, so read in as a 256x320x3 uint8 data set.

I am looking to extrapolate from this data the seperate colours I am using and export these to a data table thus:

object map 1: U,V
object map 2: U,V ... etc

I have tried to use the unique action in Matlab to do this but even unsorted I stil get far too many values. The coloured image is in effect blobs of the same colour (only 10 colours were used). How can I create a colour map from this image and store the data as a table?

Kind regards,

Matthew Bennett
From: ImageAnalyst on
Matthew Bennett
I'm not sure about YUV since I deal just with RGB and HSV, but to get
a color map from an RGB image you just need to quantize your image
into some fewer specified number of colors, for example 64 or 256,
down from the 16 million or so that it may have. See this web site
for algorithms to do this:
http://en.wikipedia.org/wiki/Color_quantization

From: Matthew Bennett on
Hi,

Thanks for the advice. I'm ok on the colour side - its working out how to filter the resultant data that is the problem.

Basically rather than RGB I am using 2 colour channels and a luminance channel. The 2 chrominance channels are the only two that are important for the moment. They are stored as a heightxwidth 2D array. Both are the same dimensions as come from the same pixel source.

Here's the image I'm working on. As you can see its chrominance only with luminance set to 128 (deliberate):

http://colourisation.files.wordpress.com/2010/08/colmap.jpg

Rather than a normal image this is just the chrominance values for a given area of an image. I have used one block of colour over an area (like on maps to determine countries).

So I have results like: ... 128,128,128,128,128,128,234,234,234,234...

I need to first mix U and V together - the result represents the true chrominance (otherwise I may get incorrect readings), then from the UV 2D array be able to parse this and select where there is duplication, filtering this doen to the coloured areas. On the image I only coloured aroung 10 areas, so should only be left with 10 entries.

I can then reverse the process thus:

(U+V) at a specific point - V = U

Now that U and V are known and Y = 128, YUV is known.

Colourspace conversion back to RGB and save in the table.

At least - that's the plan!