Article View: comp.sys.mac.programmer.codewarrior
Article #669Re: Red Eye Removing, How?
From: Chris
Date: Fri, 10 Oct 2003 14:55
Date: Fri, 10 Oct 2003 14:55
59 lines
3625 bytes
3625 bytes
In article <7328a61a.0310092311.7ba03fa1@posting.google.com>,
heroin_c@hotmail.com (wall) wrote:
> I use this code selected the rect which has red eyes.
>
> // the selected rect which has red eye
> // the selected image part GWorld - theSelectImageGWorld
> LGWorld* theSelectImageGWorld = NEW LGWorld( theSelectRect,32 );
> ThrowIfNil_( theSelectImageGWorld );
>
> // the orignal image GWorld - theImageGWorld
> PixMapHandle theOPixMapH = ::GetGWorldPixMap(
> theImageGWorld->GetMacGWorld() );
> PixMapHandle theSelectPixMapH = ::GetGWorldPixMap(
> theSelectImageGWorld->GetMacGWorld() );
> Ptr theOBaseAddr = ::GetPixBaseAddr( theOPixMapH );
> Ptr theSelectBaseAddr = ::GetPixBaseAddr( theSelectPixMapH );
> short theORowBytes = ::GetPixRowBytes( theOPixMapH );
> short theSelectRowBytes = ::GetPixRowBytes( theSelectPixMapH );
>
> ::LockPixels( theOPixMapH );
> ::LockPixels( theSelectPixMapH );
> {
> Ptr theSrcPtr, theDstPtr;
> for(short theY = mSelRectToImageOrignal.top; theY <
> mSelRectToImageOrignal.bottom; theY++)
> {
> theSrcPtr = theOBaseAddr + theORowBytes * theY;
> theSrcPtr += mSelRectToImageOrignal.left << 2;
> theDstPtr = theSelectBaseAddr + theSelectRowBytes * ( theY -
> mSelRectToImageOrignal.top );
> for (short theX = mSelRectToImageOrignal.left; theX <
> mSelRectToImageOrignal.right; theX++)
> {
> * ((long*) theDstPtr++) = * ((long*) theSrcPtr++);
> * ((long*) theDstPtr++) = * ((long*) theSrcPtr++);
> * ((long*) theDstPtr++) = * ((long*) theSrcPtr++);
> * ((long*) theDstPtr++) = * ((long*) theSrcPtr++);
>
> }
> }
> }
> ::UnlockPixels( theOPixMapH );
> ::UnlockPixels( theSelectPixMapH );
>
> what can I do to removing red eye in the selected image part?
As long as you can be relatively sure that the user has selected a close
boundary around the pupil, you could just reduce the red level
everywhere to the average of the green and blue values. This will help
establish a reasonable intensity for the red channel and will capture
any residual hilights that might be present. You may still need to bring
down the overall intensity of each channel by some fixed percentage to
avoid overly bright pupils.
Each 32-bit pixel is layed out as argb, 8 bits each. You should leave
the a value alone.
Chris.
Technical Details
Message-ID:
<nospam-0892E1.10554110102003@netnews.attbi.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeeds.sol.net!chcgil2-snh1.gtei.net!news.bbnplanet.com!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc01.POSTED!not-for-mailReferences:
<7328a61a.0310092311.7ba03fa1@posting.google.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f98ee,ac196c6d17a8acce X-Google-Attributes: gidf98ee,public X-Google-Thread: f635e,ac196c6d17a8acce X-Google-Attributes: gidf635e,public X-Google-Thread: 10bcce,ac196c6d17a8acce X-Google-Attributes: gid10bcce,public X-Google-Thread: 11100c,ac196c6d17a8acce X-Google-Attributes: gid11100c,public X-Google-ArrivalTime: 2003-10-10 07:55:42 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeeds.sol.net!chcgil2-snh1.gtei.net!news.bbnplanet.com!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc01.POSTED!not-for-mail From: Chris <nospam@mindspring.com> Newsgroups: comp.sys.mac.programmer.codewarrior,comp.os.ms-windows.programmer.tools.misc,codewarrior.mac,comp.sys.mac.programmer.tools Subject: Re: Red Eye Removing, How? References: <7328a61a.0310092311.7ba03fa1@posting.google.com> User-Agent: MT-NewsWatcher/3.2 (PPC Mac OS X) Message-ID: <nospam-0892E1.10554110102003@netnews.attbi.com> Lines: 59 NNTP-Posting-Host: 24.98.65.110 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc01 1065797741 24.98.65.110 (Fri, 10 Oct 2003 14:55:41 GMT) NNTP-Posting-Date: Fri, 10 Oct 2003 14:55:41 GMT Organization: Comcast Online Date: Fri, 10 Oct 2003 14:55:41 GMT