Documente Academic
Documente Profesional
Documente Cultură
Setup Homework 1:
switch (channel)
{
//Blue: set Red channel and Green channel to zero
case 0: cvlib.CvSetZero(ref planes[1]);
cvlib.CvSetZero(ref planes[2]);
break;
//Green: set Red channel and Blue channel to zero
case 1: cvlib.CvSetZero(ref planes[0]);
cvlib.CvSetZero(ref planes[2]);
break;
//Red: set Blue channel and Green channel to zero
case 2: cvlib.CvSetZero(ref planes[0]);
cvlib.CvSetZero(ref planes[1]);
break;
//Yellow: set Blue channel to zero
case 3: cvlib.CvSetZero(ref planes[0]);
break;
//Magenta: set Green channel to zero
case 4: cvlib.CvSetZero(ref planes[1]);
break;
//Cyan: set Red channel to zero
case 5: cvlib.CvSetZero(ref planes[2]);
break;
//Black: K = min{R,G,B}
case 6:
cvlib.CvMin(ref planes[0], ref planes[1], ref temp);
cvlib.CvMin(ref planes[2], ref temp, ref temp);
cvlib.CvCvtColor(ref temp, ref output, cvlib.CV_GRAY2BGR);
break;
}
if (channel < 6)
cvlib.CvMerge(ref planes[0], ref planes[1], ref planes[2], ref output);
return output;
}
switch (channel)
{
//Hue: is planes[0]
case 0: cvlib.CvCvtColor(ref planes[0], ref output, cvlib.CV_GRAY2BGR);
break;
//Saturation: is planes[1]
case 1: cvlib.CvCvtColor(ref planes[1], ref output, cvlib.CV_GRAY2BGR);
break;
//Value: is planes[2]
case 2: cvlib.CvCvtColor(ref planes[2], ref output, cvlib.CV_GRAY2BGR);
break;
}
return output;
}
switch (channel)
{
//Y (Y is the luma component, or the brightness)
case 0: cvlib.CvCvtColor(ref planes[0], ref output, cvlib.CV_GRAY2RGB);
break;
return output;
}
switch (channel)
{
//X, which can be compared to red
case 0: cvlib.CvCvtColor(ref planes[0], ref output, cvlib.CV_GRAY2BGR);
break;
//Y, which can be compared to green
case 1: cvlib.CvCvtColor(ref planes[1], ref output, cvlib.CV_GRAY2BGR);
break;
//Z, which can be compared to blue
case 2: cvlib.CvCvtColor(ref planes[2], ref output, cvlib.CV_GRAY2BGR);
break;
}
return output;
}
Results:
Black
Y Cr Cb