-
Notifications
You must be signed in to change notification settings - Fork 3
Changing an image's colorspace
Romain Milbert edited this page Jul 26, 2017
·
5 revisions
With ArcV, it is extremely easy to modify an image's colorspace. It just requires one function call, where the parameter mat
is an image:
Arcv::Matrix<float> res = Arcv::Image::changeColorspace<ARCV_COLORSPACE_XXXXX>(mat); // "mat" is an Arcv::Mat (or Arcv::Matrix<>)
The template ARCV_COLORSPACE_XXXXX
is to be subsituted with any of the following values:
ARCV_COLORSPACE_GRAY // Grayscale
ARCV_COLORSPACE_GRAY_ALPHA // Grayscale with alpha channel
ARCV_COLORSPACE_RGB // Red/Green/Blue, standard colorspace
ARCV_COLORSPACE_RGBA // RGB with alpha channel
ARCV_COLORSPACE_HSV // Hue/Saturation/Value, useful in case of color thresholding
And here goes! Just write your image to a file if you want to see the result:
Arcv::Image::write("output.png", res);
Original image (simple RGB colorspace):
Colorspace | Output image |
---|---|
ARCV_COLORSPACE_GRAY | |
ARCV_COLORSPACE_HSV |
Note: HSV's output is not meant to be shown, this is why the result is nonsense.