Red-eye reduction in Visual Basic using the csXImage control.

The "Red-Eye" effect spoils many otherwise perfect photos. Even though digital cameras usually have a flash setting that prevents red-eye, how often do we forget to select that option?

Removing the red glare from the eye is very simple in applications that use csXImage. The method is demonstrated in the Visual Basic demo program supplied in the csXImage download.

The photo is corrected in two steps.

(1) A region around the eye, usually an ellipse or a circle, is selected. This requires just one line of code.


(2) After the user completes the selection using the mouse, two further lines of code adjust the red intensity for pixels where it is the dominant colour.

ImageBox1.UseSelection = True

The result is shown below.

ActiveX loading a photograph in VB

Original photo

ActiveX selecting an image area in VB

Selecting the red-eye

ActiveX removing red eye in a VB image

The final result

<<Previous page

function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } function AcceptCookies() { createCookie("cookie-site","true",120); createCookie("cookie-tracking","true",120); createCookie("cookie-remarketing","true",120); document.getElementById("overlay").style.display = "none"; } ]]>


This site uses cookies for functionality, traffic analysis and for targeted advertising. Click the Accept button to accept our Cookie Policy. The Cookie Policy page offers configuration for a reduced set of cookies for this site.