Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

here you go:

void cmyk2rgb(const Mat & c,const Mat & m,const Mat & y,const Mat & k, Mat & rgb ) {
    rgb = Mat(c.size(), CV_8UC3);
    for ( size_t j=0;j<c.rows; j++ ) {
        for ( size_t i=0;i<c.rows; i++ ) {
            Vec3b & v = rgb.at<Vec3b>(i,j);
            uchar K = k.at<uchar>(i,j);
            v[2] = saturate_cast<uchar>(K - ((255 - c.at<uchar>(i,j))*K>>8));
            v[1] = saturate_cast<uchar>(K - ((255 - m.at<uchar>(i,j))*K>>8));
            v[0] = saturate_cast<uchar>(K - ((255 - y.at<uchar>(i,j))*K>>8));
        }
    }
}