2012-04-06 5 views
0

opencv2 C++ 인터페이스를 사용하고 있습니다.색상 표현 : 스칼라에서 부동 및 그 반대로

스칼라에서 색상을 변환하는 방법을 알고 싶습니다. 이 같은 매트릭스 가지고

d = Mat(src.rows, src.cols, CV_32F); 

및 I은 RGB (255) 값과 스칼라에 표시되는 컬러로의 일부를 채우도록 할하십시오 float CV 일부 요소를 변환

for(int i=0; i<src.cols*src.rows; i++) 
    if (some_condition) 
     // fill it with red 
     d.at<float>(i/src.cols, i%src.cols) =? Scalar(255,0,0); 

답변

2

:: 매트 이력서 :: 매트 클래스의이 방법을 확인

// sets some of the matrix elements to s, according to the mask 
    Mat& setTo(const Scalar& s, const Mat& mask=Mat()); 

http://opencv.willowgarage.com/documentation/cpp/basic_structures.html

매트릭스의 어느 부분이 if statement의 조건을 만족시키는 지 정의하는 마스크를 정의해야합니다.

관련 문제