Hayri Uğur Koltuk Hayri Uğur Koltuk - 1 month ago 9
C# Question

How to convert Bgr pixel to Hsv pixel in EmguCV?

I'd like to convert a Bgr value (one pixel) to an Hsv value. How can I do that (without writing the conversion code from scratch) in EmguCV?

Please note that I am not interested in converting whole image's color space but only one pixel, therefore

does not work for me.

Answer Source

Okay I already found a way using some help from .NET framework

given a Bgr pixel ;

1- Converting the color to System.Drawing.Color :

System.Drawing.Color intermediate = System.Drawing.Color.FromArgb((int)pixel.Red, (int)pixel.Green, (int)pixel.Blue);

2- Constructing Hsv from the intermediate.

Hsv hsvPixel = new Hsv(intermediate.GetHue(), intermediate.GetSaturation(), intermediate.GetBrightness());