Scaled Divide

1 개요

이미지 혹은 Scalar 값을 사용하여 Scaled Divide 연산을 수행하는 알고리즘입니다.

2 알고리즘 상세 설명

Scaled Divide의 연산은 다음 식을 활용합니다.

ScaledDivide(a,b)={a/bMAX,b0DivideZero(a),b=0ScaledDivide(a, b) = \begin{cases} a / b * MAX, & b\neq0\\ DivideZero(a), & b=0\\ \end{cases}

DivideZero(a)={MIN,a<00,a=0MAX,a>0DivideZero(a) = \begin{cases} MIN, & a<0\\ 0, & a=0\\ MAX, & a>0\\ \end{cases}

변수 MAX의 값은 a 변수의 최댓값을 뜻합니다.

Source Value Operand Value Destination Value
Source Image Operation Image Destination Image
Fig. Source, Operand and Destination values of Scaled Divide

a가 float 혹은 double인 경우 MAX를 1로 설정하여 일반적인 나누기 연산을 실행합니다.

Source Value Operand Value Destination Value
Source Image Operation Image Destination Image
Fig. Floating Source, Operand and Destination values of Scaled Divide

나누는 값이 0이고 a가 float/double이 아닌 경우 a가 양수이면 최대 값, a가 음수이면 최소 값, a가 0이면 0을 반환합니다.

Source Value Operand Value Destination Value
Source Image Operation Image Destination Image
Fig. Source, Zero Operand and Destination values of Scaled Divide

3 예제 코드

Scalar 연산

COperationScaledDivide operationScaledDivide;

CFLImage fliSourceImage;
CFLImage fliDestinationImage;
CMultiVar<double> mulVarScalar;

operationScaledDivide.SetSourceImage(fliSourceImage);
operationScaledDivide.SetDestinationImage(fliDestinationImage);
operationScaledDivide.SetOperationSource(EOperationSource_Scalar);
operationScaledDivide.SetScalarValue(mulVarScalar);

operationScaledDivide.Execute();
COperationScaledDivide operationScaledDivide = new COperationScaledDivide();

CFLImage fliSourceImage = new CFLImage();
CFLImage fliDestinationImage = new CFLImage();
CMultiVar<double> mulVarScalar = new CMultiVar<double>();

operationScaledDivide.SetSourceImage(ref fliSourceImage);
operationScaledDivide.SetDestinationImage(ref fliDestinationImage);
operationScaledDivide.SetOperationSource(EOperationSource.Scalar);
operationScaledDivide.SetScalarValue(mulVarScalar);

operationScaledDivide.Execute();

Image 연산

COperationScaledDivide operationScaledDivide;

CFLImage fliSourceImage;
CFLImage fliOperandImage;
CFLImage fliDestinationImage;

operationScaledDivide.SetSourceImage(fliSourceImage);
operationScaledDivide.SetOperandImage(fliOperandImage);
operationScaledDivide.SetDestinationImage(fliDestinationImage);
operationScaledDivide.SetOperationSource(EOperationSource_Image);

operationScaledDivide.Execute();
COperationScaledDivide operationScaledDivide = new COperationScaledDivide();

CFLImage fliSourceImage = new CFLImage();
CFLImage fliOperandImage = new CFLImage();
CFLImage fliDestinationImage = new CFLImage();

operationScaledDivide.SetSourceImage(ref fliSourceImage);
operationScaledDivide.SetOperandImage(ref fliOperandImage);
operationScaledDivide.SetDestinationImage(ref fliDestinationImage);
operationScaledDivide.SetOperationSource(EOperationSource.Image);

operationScaledDivide.Execute();