Beispiel #1
0
int main(int argc, char** argv) {

	// Create a named window with a the name of the file.
	cvNamedWindow(argv[1], 1);

	// Load the image from the given file name.
	IplImage* src = cvLoadImage(argv[1]);
	IplImage* dst = cvCreateImage(cvGetSize(src), src->depth, 1);
	sum_rgb(src, dst);

	// Show the image in the named window
	cvShowImage(argv[1], dst);

	// Idle until the user hits the "Esc" key.
	while (1) {
		if ((cvWaitKey(10) & 0x7f) == 27)
			break;
	}

	// Clean up and don’t be piggies
	cvDestroyWindow(argv[1]);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);

}
// Fixme: Pass a channel_t instead, and quantize outside
static AlphaMap desaturate_AlphaMap(const Bitmap& bmp){
  AlphaMap a(bmp.GetSize());
  for (int y = 0; y != bmp.m_h; y++){
    for (int x = 0; x != bmp.m_w; x++){
      Color c(get_color_raw(bmp, x, y));
      a.Set(x, y, static_cast<uchar>(sum_rgb(c) / 3));
    }
  }
  return a;
}
Beispiel #3
0
int main(int argc, const char *argv[])
{
    // Create a named window with the name of the file
    cvNamedWindow(argv[1], 1);

    // Load the image from the given file name
    IplImage *src = cvLoadImage(argv[1]);
    IplImage *dst = cvCreateImage(cvGetSize(src), src->depth, 1);
    sum_rgb(src, dst);

    // Show the image in the named window
    cvShowImage(argv[1], dst);

    // Idle until the user hits the 'Esc' key
    while(1) { if((cvWaitKey(10)&0x7f) == 27) break;}
    cvDestroyWindow(argv[1]);
    cvReleaseImage(&src);
    cvReleaseImage(&dst);
    return 0;
}