Compare

1 개요

스칼라 또는 이미지와의 Compare 연산을 수행하는 알고리즘입니다. 이미지의 픽셀값을 비교해 스칼라 또는 대응하는 이미지의 픽셀값보다 작은 경우와 큰 경우 또는 같은 경우로 나눠서 각 경우에 해당하는 값으로 결과 이미지를 생성합니다.

2 알고리즘 상세 설명

Source Operand Destination
Source Image Operation Image Destination Image
Fig. Singed Format에서의 결과

기본적으로 Source의 Format이 Signed인 경우, 대응하는 값과 같은 경우에는 0, 대응하는 값보다 큰 경우에는 1, 작은 경우에는 -1를 출력합니다.

Source Operand Destination
Source Image Operation Image Destination Image
Fig. Unsinged 8bit Format에서의 결과

Unsigned Format에서는 -1에 해당하는 값이 없으므로 대응하는 값보다 작은 경우 해당 Format의 MAX값을 출력합니다.

Source Operand Destination
Source Image Operation Image Destination Image
Fig. 1bit Format에서의 결과

1bit Format을 지원하며, 해당 경우 대응하는 값과 같으면 0, 다르면 1을 출력합니다. Format과 상관없이 값 그 자체를 비교하므로 0과 1이 아닌 값을 대응시키면 무조건 1을 출력합니다.

비교 연산 자체는 Source와 Operand를 모두 포함하는 가장 큰 Format에서 진행하므로 두 비교 대상의 Format이 달라도 Compare연산의 결과는 출력됩니다. 비교 대상의 Format의 전체 범위와는 상관없이 값 그 자체를 비교 대상으로 삼습니다.

3 파라미터 설정 및 사용 방법

Compare Operation의 경우 format별로 수행하는 연산과 연산의 결과가 고정되어 있기 때문에 특별한 파라미터는 존재하지 않습니다. 다른 format의 결과를 얻고 싶다면 FormatConverter를 사용하여 format 변환 후 Compare Operation을 진행하면 됩니다.

4 예제 코드

Scalar 연산

COperationCompare operationCompare;

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

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

operationCompare.Execute();
COperationCompare operationCompare = new COperationCompare();

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

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

operationCompare.Execute();

Image 연산

COperationCompare operationCompare;

CFLImage fliSourceImage;
CFLImage fliOperandImage;
CFLImage fliDestinationImage;

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

operationCompare.Execute();
COperationCompare operationCompare = new COperationCompare();

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

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

operationCompare.Execute();

5 관련 알고리즘

CDifference, CGreater, CLesser