[ImageAlgorithm] Color image segmentation Topic 1: display the color value of any point on the screen
Skyseraph may 13rd 2011 hqu
Email: zgzhaobo@gmail.com QQ: 452728574
Latest modified date: May 13rd 2011 hqu
Note:
1. When analyzing a color image, you need to know the color value of a certain point in the image in real time for the selection of different spaces. For more information, see online materials, display the RGB, HSV, and yiq values of any point on the screen in real time. Of course, they can also be values of other color spaces. The principle is similar to none.
2. For more information about color space, see:
Http://www.cnblogs.com/skyseraph/archive/2011/05/03/2035643.html
Http://www.cnblogs.com/skyseraph/archive/2011/05/05/2038317.html
Http://www.cnblogs.com/skyseraph/archive/2011/05/05/2038308.html
3. Similar Software
Http://www.broadhurst-family.co.uk/lefteye/MainPages/Lab.htm RGB/lab/HSV Software
Implementation (source code ):
Response Functions
//////////////////////////////////////// /// // Void ccolorsegdlg:: onfetchcolor () // obtain the RGB value of any point on the screen and display {m_bsnapflag ^ = true; If (m_bsnapflag) // enable the screen color {m_colorpicker.setwindowtext ("Stop fetch "); setwindowpos (& wndtopmost, 0, 0, 0, 0, swp_nomove | swp_nosize); settimer (1, 80, null ); // trigger a timer for 80 ms} else {m_colorpicker.setwindowtext ("START fetch"); setwindowpos (& wndnotopmost, 0, 0, 0, 0, swp_nomove | swp_nosize ); killtimer (1);} // Note: Another method is not to use bool to mark m_bsnapflag, // If (m_colorpicker.getcheck (), but this method cannot implement Menu Control}
Time Function
Void ccolorsegdlg: ontimer (uint nidevent) {If (nidevent! = 1) return; cpoint pt; getcursorpos (& pt); HDC =: getdc (null); colorref CLR =: getpixel (HDC, PT. x, PT. y); int r = getrvalue (CLR); int G = getgvalue (CLR); int B = getbvalue (CLR); // output the RGB value cstring clrtext; clrtext. format ("% d", R); // getrvalue (CLR) m_editred.setwindowtext (clrtext); clrtext. format ("% d", g); // getgvalue (CLR) m_editgreen.setwindowtext (clrtext); clrtext. format ("% d", B); // getbvalue (CLR) m_editblue.setwindowtext (clrtext); cstring Cs; // HSV double HSV H, HSV S, HSV V; pmycolorspace. myrgb2hsv (R, G, B, HSV H, HSV S, HSV V, 1); // output the HSV value CS. format ("%. 3f ", hsv h); getdlgitem (idc_h)-> setwindowtext (CS); CS. format ("%. 3f ", hsv s); getdlgitem (idc_s)-> setwindowtext (CS); CS. format ("%. 3f ", hsv v); getdlgitem (idc_v)-> setwindowtext (CS); // YUV & yiqdouble yuvy, yuvu, yuvv, yiqy, Yiqi, yiqq; pmycolorspace. myrgb2yuv (R, G, B, yuvy, yuvu, yuvv); pmycolorspace. myrgb2yiq (R, G, B, yiqy, Yiqi, yiqq); // int nth = int (atan (FABS (yuvv/yuvu) * 180.0/3.1415926 ); // output the yiq value CS. format ("%. 3f ", yiqq); getdlgitem (idc_yiqq)-> setwindowtext (CS); CS. format ("%. 3f ", Yiqi); getdlgitem (idc_yiqi)-> setwindowtext (CS); CS. format ("%. 3f ", yiqy); getdlgitem (idc_yiqy)-> setwindowtext (CS); // display area crect m_rect; m_color.getclientrect (m_rect); CDC * Dc = m_color.getdc (); cbrush m_brush (RGB (getrvalue (CLR), getgvalue (CLR), getbvalue (CLR); DC-> fillrect (m_rect, & m_brush);: releasedc (null, HDC); cdialog: ontimer (nidevent );}
Effect
For the complete interface, see:
Http://www.cnblogs.com/skyseraph/archive/2011/05/05/2038308.html
Author: skyseraph
Email/Gtalk: zgzhaobo@gmail.com QQ: 452728574
From: http://www.cnblogs.com/skyseraph/
The copyright of this article is shared by the author and the blog. You are welcome to repost this article, but you must keep this statement without the author's consent andArticleThe original text connection is clearly displayed on the page. Please respect the author's Labor achievements.