Class: OpenCV::CvScalar

Inherits:
Object
  • Object
show all
Defined in:
ext/opencv/cvscalar.cpp

Overview

Element-value of one pixel. OpenCV supports the image of 4-channels in the maximum. Therefore, CvScalar has 4-values.

C structure is here, very simple.

typdef struct CvScalar {
  double val[4];
} CvScalar;

If obtain CvScalar-object from the method of CvMat(or IplImage), the channel outside the range is obtained as all 0.

image = IplImage::load("opencv.jpg")  #=> 3-channel 8bit-depth BGR image
pixel = image[10, 20]                 #=> Get pixel value of (10, 20) of image. pixel is CvScalar-object.
blue, green, red = pixel[0], pixel[1], pixel[2]
# pixel[3] always 0.

CvColor is alias of CvScalar.