To threshold one channel in RGB image or any other type it looks like this: This peace of code is inspired from a post in the OpenCV mailing.
In case you want to threshold the blue channel for example, so follow this steps
You would first split the BGR image in the three channels:
cvSplit(BGRimg, Bimg, Gimg, Rimg)
Then, use thresholding to theshold the blue plane to a binary image according to whatever criteria you need (i.e. a 1 is a pixel to keep a 0 is a pixel to discard):
cvThreshold(Bimg, Bimgthresh, ….criteria…)
the use this thresholded image as a “mask” to filter the channels by simple multiplication:
cvMul(Bimg, Bimgthresh, Bimg) cvMul(Gimg, Bimgthresh, Gimg) cvMul(Rimg, Bimgthresh, Rimg)
then recombine the planes into the image
cvMerge(Outimg, Bimg, Gimg, Rimg)