Opencv + C/C++ [ binarização de uma imagem] [resolvido]

Ola pessoal,

Estou tentando binarizar uma imagem usando essa função do opencv:

cvThreshold(imageGrayScale,
		imageBinary,
		100, //pontoDeCorte
		255,
		CV_THRESH_BINARY);

Porém ao percorrer a imagem eu encontro :

#define get_channel(i, j, frame, channel) ((uchar *)(frame->imageData + j*frame->widthStep))[i*frame->nChannels + channel]
#define set_channel(i, j, frame, channel, value) ((uchar*)(frame->imageData + j*frame->widthStep))[i*frame->nChannels + channel] = value

//..+ code

neighbor[0] = get_channel(i-1,j,image,c);

printf("dif  %d",get_channel(i-1,j,image,c));// aqui a saída é 186

Se a imagem é binária eu teria só 0 ou 255, que seria preto ou branco.

Com base nesse código alguém saberia me dizer como binarizar a imagem?

ou se estiver certo a binarização,

Pq em um dado momento o meu retorno é de 186 no get_channel?

eu estava pegando um endereço de memória, quando devia pegar o valor.

Só por curiosidade olha como fazer isso é legal em JAVA

void binary(){

		float threshold = 127;
		for (int x = 0; x < source.width; x++) {
			for (int y = 0; y < source.height; y++) {
				int loc = x + y * source.width;
				// Test the brightness against the threshold
				if (brightness(source.pixels[loc]) > threshold) {
					destination.pixels[loc] = color(255); // White
				} else {
					destination.pixels[loc] = color(0); // Black
				}
			}
		}
	}