REVO2700 Do I Need A Haircut? P constant HAIR_THRESHOLD = 75 constant FACE_THRESHOLD = 120 constant RED_WEIGHT = 0.8 constant BLUE_WEIGHT = 1.0 constant GREEN_WEIGHT = 1.0 constant HAIR_COLOUR = 0 constant FACE_COLOUR = 127 constant BG_COLOUR = 255 function DoINeedAHaircut @pImage, pWidth, pHeight local tHairCount, tFaceCount repeat with y = 1 to pHeight repeat with x = 1 to pWidth local tRed, tGreen, tBlue, tAlpha put charToNum(char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 2 of pImage) into tRed put charToNum(char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 3 of pImage) into tGreen put charToNum(char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 4 of pImage) into tBlue put charToNum(char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 1 of pImage) into tAlpha if (tRed * RED_WEIGHT + tGreen * GREEN_WEIGHT + tBlue * BLUE_WEIGHT) / 3 < HAIR_THRESHOLD then put numToChar(HAIR_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 2 of pImage put numToChar(HAIR_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 3 of pImage put numToChar(HAIR_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 4 of pImage add 1 to tHairCount else if (tRed * RED_WEIGHT + tGreen * GREEN_WEIGHT + tBlue * BLUE_WEIGHT) / 3 < FACE_THRESHOLD then put numToChar(FACE_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 2 of pImage put numToChar(FACE_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 3 of pImage put numToChar(FACE_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 4 of pImage add 1 to tFaceCount else put numToChar(BG_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 2 of pImage put numToChar(BG_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 3 of pImage put numToChar(BG_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 4 of pImage end if end repeat end repeat return tHairCount > tFaceCount end DoINeedAHaircut T U Lucida Grande cREVGeometryCache stackID 1011 cREVGeneral scriptChecksum O(p8*f+~ debugObjects breakPoints handlerList DoINeedAHaircutscriptSelection char 1917 to 1916 bookmarks tempScript prevHandler DoINeedAHaircut1stackfileversion 2.7script >
constant HAIR_THRESHOLD = 75
constant FACE_THRESHOLD = 120
constant RED_WEIGHT = 0.8
constant BLUE_WEIGHT = 1.0
constant GREEN_WEIGHT = 1.0
constant HAIR_COLOUR = 0
constant FACE_COLOUR = 127
constant BG_COLOUR = 255
function DoINeedAHaircut @pImage, pWidth, pHeight
local tHairCount, tFaceCount
repeat with y = 1 to pHeight
repeat with x = 1 to pWidth
local tRed, tGreen, tBlue, tAlpha
put charToNum(char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 2 of pImage) into tRed
put charToNum(char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 3 of pImage) into tGreen
put charToNum(char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 4 of pImage) into tBlue
put charToNum(char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 1 of pImage) into tAlpha
if (tRed * RED_WEIGHT + tGreen * GREEN_WEIGHT + tBlue * BLUE_WEIGHT) / 3 < HAIR_THRESHOLD then
put numToChar(HAIR_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 2 of pImage
put numToChar(HAIR_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 3 of pImage
put numToChar(HAIR_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 4 of pImage
add 1 to tHairCount
else if (tRed * RED_WEIGHT + tGreen * GREEN_WEIGHT + tBlue * BLUE_WEIGHT) / 3 < FACE_THRESHOLD then
put numToChar(FACE_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 2 of pImage
put numToChar(FACE_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 3 of pImage
put numToChar(FACE_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 4 of pImage
add 1 to tFaceCount
else
put numToChar(BG_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 2 of pImage
put numToChar(BG_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 3 of pImage
put numToChar(BG_COLOUR) into char ((y - 1) * pWidth * 4) + ((x - 1) * 4) + 4 of pImage
end if
end repeat
end repeat
return tHairCount > tFaceCount
end DoINeedAHaircut
@ T cREVGeometryCacheIDs 1201171388898 10111201166754822 10051201167179920 10091201166718420 1004 cREVGeometrycache total 4order Source Image d @ PNG IHDR @ q-k gAMA =-f IDATxĽݒ$ɍjSUd"3/W+ӽ&Y?f `/fՒc")ann s?_6ueDqFkcp{;8AFiy*!R~ ;9U"fF1|!y^@Dy^Gp>6<|]5'ax^.*Z1/#x;Q]FSyf=?oTI;CZ T=}vwND`fD]p8cbQQ,=?/yJ _QFGzѕc?03QD~˗6St7Ow3RKPkwVp_p8swc>q<ϯZy35>|. V|>Z~u`(`2|N/53MRsF^/xh)pj1XmPk%:hM=}&(-d&gϯ);zp=Q#g B[/SJA|k XsY^g[U >ePWJQ :" E(Pw ף.3()ꊖB0 K^{ECAՎ3c*e(8BuG%ȅaF\PFV|TαwT+A8G?8| B\(yyR o$"Q(Eq "^]FN)Jpa@ȏo tFϨ(71J)t PNpZnĪst:0s.0A}ᶱN'ڇ+?#\߮˟?3oR%7Ǐ+O?rb@8I?v{?r2ow~G~\aq=X@T9EN1L9ƍV+E2-bs4Ră"BPU,, J)x|h-(:cP=ˢ~Ʊ!*g e gA)=@PB!3F=ls}#_ $8ټВj0N6ZhRpwJmgyޘ#`P 0R((⁸!"Ԧ yc(,UD Q,WZ)xLPB]ڼoc|L@RRP-8=G EX8xe~UEP`9.7y|fFUc'DM!0HԺʙVApuCDq5 s.<#DN-B/ԞnpcxPKFTDsG8ՠv'c?l'e][.w|Wb|;vvpn7aŜuYxӏ|KF|?²g;/=t!"X3kO?qiD늛qJEA])z(P*Ѕnp[m0\uV T;(6*m#zV0R03