Vote count:
0
ive been working on a program that takes a tiff image and splits the image up into colour layers depending on how many different colours it has, each image can have between 3 and 24 main colours, but ive found out that there are slight variations on the colours which is making it difficult to separate the layers, I ended up mapping all the colours which one image had
eg: this is just one colour and the main colour is ARGB 255, 25, 176, 235 which is a light blue
mapList.Add(new KeyValuePair<Color, Color>(Color.FromArgb(255, 30, 175, 222), Color.FromArgb(255, 25, 176, 235)));
mapList.Add(new KeyValuePair<Color, Color>(Color.FromArgb(255, 32, 180, 240),Color.FromArgb(255, 25, 176, 235)));
mapList.Add(new KeyValuePair<Color, Color>(Color.FromArgb(255, 20, 173, 229),Color.FromArgb(255, 25, 176, 235)));
mapList.Add(new KeyValuePair<Color, Color>(Color.FromArgb(255, 18, 174, 237),Color.FromArgb(255, 25, 176, 235)));
mapList.Add(new KeyValuePair<Color, Color>(Color.FromArgb(255, 29, 175, 222), Color.FromArgb(255, 25, 176, 235)));
mapList.Add(new KeyValuePair<Color, Color>(Color.FromArgb(255, 29, 179, 239),Color.FromArgb(255, 25, 176, 235)));
id then iterate through all the pixels changing the variant colours into the main colour, which worked ok but its not really an algorithm, ideally I want to change the bitmap colours into its closest known colour, Id quantize then use Euclidean distance between colours (tolerance needs to be quite wide), cosine angle (vectors are to small RGB 1,1,1 is closer to 11,11,11 than 2,2,2). Ive tried changing it to GIF and PNG but they seem to have many more colours and im losing quality. performance isn't an issue as im using lockbits so I don't care how many times I have to iterate over a bitmap. Im not asking for code, or even to write an algo, just a pointer in the right direction. Regards
color mapping bitmap into seperate bitmaps c#
Aucun commentaire:
Enregistrer un commentaire