void MainWindow::on_Threshold_clicked()
{
    this->setEnabled(false);

    ThresHoldWindow threshold_window(this,_Image.getHandledData());
    threshold_window.exec();

    this->setEnabled(true);
}
Esempio n. 2
0
/**
 * @brief thresholds an image in a localised, adaptive way, allowing large
 *        illumination variations to exist in the source image and still be
 *        able to thresholded well
 *
 * @param frame        the frame to threshold
 * @param window_size  the size of the window to use (must be odd, small is
 *                     faster and less susceptible to illumination variations)
 * @param c            a constant to subtract from the threshold before it's
 *                     applied to de-clutter the output somewhat. Good values
 *                     are small, perhaps no greater than 10.
 * @param method       the method to use when thresholding a window, choose from
 *                     { KOKI_ADAPTIVE_MEAN, KOKI_ADAPTIVE_MEDIAN }
 */
IplImage* koki_threshold_adaptive(IplImage *frame, uint16_t window_size,
				  int16_t c, uint8_t method)
{

	IplImage *output = NULL;
	koki_integral_image_t *iimg = NULL;

	assert(frame != NULL && frame->nChannels == 1);

	/* create the integral image to accelerate window summation */
	iimg = koki_integral_image_new( frame, true );

	/* create output image */
	output = cvCreateImage(cvGetSize(frame),
			       frame->depth,
			       frame->nChannels);

	assert(output != NULL);

	if (method == 0) /* default */
		method = KOKI_ADAPTIVE_MEAN;


	/* threshold the image */
	for (uint16_t y=0; y<frame->height; y++){
		for (uint16_t x=0; x<frame->width; x++){

			threshold_window(frame, iimg, output, x, y,
					 window_size, c, method);

		}//for
	}//for

	koki_integral_image_free( iimg );

	return output;

}