PDA

Просмотр полной версии : Программно убрать эффект красных глаз


54321go
20.03.2007, 13:57
Подскажите пожалусто. Как возможно программно убрать эффект красных глаз? Может есть готовый пример.

iNils
20.03.2007, 14:17
Опуститесь с небес на землю.

54321go
20.03.2007, 14:21
:) iNils это что-ли невозможно?

iNils
20.03.2007, 14:30
Ну почему же, указывайте область красных глаз и пишите фильтр для удаления.
А про землю, это про готовые примеры.

etc
20.03.2007, 14:33
BitmapData в руки и вперед!

Tardos Mors
20.03.2007, 18:09
А зачем программно - ИМХО легче тогда фотошопом

Dendroid
26.03.2007, 20:35
Ben Pritchard ещё в позапрошлом году очень неплохой вариант сделал:

import flash.display.BitmapData;

class RedEyeReducer{

//Ben Pritchard 2005



//Bitmap Data Object

private var pBMP:BitmapData;

//Input Mc

private var mc:MovieClip;

//Tolerances

private var toleranceRed:Number;

private var toleranceGreen:Number;

private var toleranceBlue:Number;



function RedEyeReducer(){

}



//Apply tolerances

public function setColorTolerance(r:Number,g:Number,b:Number):Void{

toleranceRed = r;

toleranceGreen = g;

toleranceBlue = b;

}



//Sets the mc to use for reduction

public function setPictureClip(mc:MovieClip):Void{

trace("MC " + mc);

mc.cRef = this;

//Creates the overlay

mc.createEmptyMovieClip("shade_mc", 2);

//Track the click and drag

mc.onPress = function(){

this.shade_mc.moveTo(this._xmouse, this._ymouse);

this.origX = this._xmouse;

this.origY = this._ymouse;

this.drawing = true;



}

//Redraw the overlay

mc.onMouseMove = function(){

if(this.drawing == true){

this.shade_mc.clear();

this.shade_mc.moveTo(this.origX,this.origY);

this.shade_mc.beginFill(0xFFFFFF,50);

this.shade_mc.lineTo(this._xmouse, this.origY);

this.shade_mc.lineTo(this._xmouse, this._ymouse);

this.shade_mc.lineTo(this.origX, this._ymouse);

this.shade_mc.lineTo(this.origX, this.origY);

this.shade_mc.endFill();

}

}

mc.onRelease = function(){

//Record the coordinates

this.endX = this._xmouse;

this.endY = this._ymouse;

//Clear the overlay

this.shade_mc.clear();

//Turn the overlay updating off

this.drawing = false;

//Create the bitmap object

var transparent:Boolean = true;

var fillColor:Number = 0xFFFFFFFF;

this.cRef.pBMP = new BitmapData(this._width, this._height, transparent, fillColor);

this.cRef.pBMP.draw(this);

this.attachBitmap(this.cRef.pBMP,1);

//Call the reduction method

this.cRef.setRedtoBlack(this.origX,this.origY,this.endX,this.endY);

}

}



private function setRedtoBlack(origX,origY,endX,endY):Void{

//Loop through the coordinate colors

trace(toleranceRed);

for(var i:Number= origX;i< endX;i++){

for(var j:Number = origY;j < endY;j++){

if(parseInt(pBMP.getPixel(i,j).toString(16).substring(0,2),16) > toleranceRed && parseInt(pBMP.getPixel(i,j).toString(16).substring(2,4),16) < toleranceGreen && parseInt(pBMP.getPixel(i,j).toString(16).substring(4,6),16) < toleranceBlue){

var currentColor = "0x" + "00" + pBMP.getPixel(i,j).toString(16).substring(2,6);

pBMP.setPixel(i,j,currentColor);

}

}

}

}



public function reset():Void{

pBMP.dispose();

}

}

Вот тут можно посмотреть как это работает:
http://pixelfumes.blogspot.com/2005/11/red-eye-removal-with-flash-8-upload.html

googleavast
26.03.2007, 23:35
Может стоит попробовать написать компонент для флэша?

etc
27.03.2007, 00:44
Может стоит попробовать написать компонент для флэша?
Ну так напишите, какие проблемы? Только как будет выглядеть сей компонент?