# Include "CV. H "# include" highgui. H "# pragma comment (Lib," cxcore200.lib ") # pragma comment (Lib," highgui200.lib ") using namespace CV; voidmousehandler (INT event, int X, int y, int flags, void * PARAM) {iplimage * img0, * img1; cvfont font; uchar * PTR; char Label [20]; img0 = (iplimage *) Param; img1 = cvcloneimage (img0 ); cvinitfont (& font, cv_font_hershey_plain ,. 8 ,. 8, 0, 1, 8); If (event = cv_event_lbutton Down) {/* read pixel */PTR = cvptr2d (img1, Y, X, null);/** display the BGR value */sprintf (label, "(% d, % d, % d) ", PTR [0], PTR [1], PTR [2]); cvrectangle (img1, cvpoint (X, Y-12 ), cvpoint (x + 100, Y + 4), cv_rgb (255, 0, 0), cv_filled, 8, 0); cvputtext (img1, label, cvpoint (x, y ), & font, cv_rgb (255,255, 0); cvshowimage ("IMG", img1) ;}} intmain (INT argc, char ** argv) {iplimage * IMG; /* usage: <Prog_name> <image> * // If (argc! = 2) {// printf ("Usage: % S <image>/N", argv [0]); // return 1; ///}/* load image */IMG = cvloadimage ("D: // 1.jpg", 1);/* always check */assert (IMG ); /* create a window and install mouse handler */cvnamedwindow ("IMG", 1); cvsetmousecallback ("IMG", mousehandler, (void *) IMG ); cvshowimage ("IMG", IMG); cvwaitkey (0);/* be tidy */cvdestroyallwindows (); cvreleaseimage (& IMG); Return 0 ;} A piece of log transferred from the blog Park !!