Binary Complement

1 개요

이미지의 값을 binary로 표현하여, Operand의 값이 11이면 11의 보수, 22이면 22의 보수를 반환합니다.

2 알고리즘 상세 설명

이진법으로 표현된 수 xx11의 보수는 주로 ~xx로 표기되며, 이는 xx의 각 자리수가 00이면 11, 11이면 00으로 변환된 값입니다. 또한 xx22의 보수란, xx와 더했을 때 00이 되는 값을 말하며, 따라서 x-x와 그 값이 같습니다.

위 두 가지 정의와 합치되면서 모든 Operand에 대해 적절한 값을 제공하기 위하여, Binary Complement의 반환값은 두 Unsigned Int x,yx, y에 대하여 f(x,y)=yx2f(x, y) = y - x - 2로 정의됩니다.

Source Value Operand Value Destination Value
Source Value Operand Value Destination Value
Fig. Source and Destination values of Binary Complement

3 예제

COperationBinaryComplement binaryComplement;

CFLImage fliSourceImage;
fliSourceImage.Load(L"Created Image");
binaryComplement.SetSourceImage(fliSourceImage);

CMultiVar<uint64_t> mvScalarValue(2, 128, 64);
binaryComplement.SetScalarValue(mvScalarValue);

binaryComplement.Execute();
COperationBinaryComplement binaryComplement = new COperationBinaryComplement();

CFLImage fliSourceImage = new CFLImage();
fliSourceImage.Load("Created Image");
binaryComplement.SetSourceImage(ref fliSourceImage);

CMultiVar<UInt64> mvScalarValue = new CMultiVar<UInt64>(2, 128, 64);
binaryComplement.SetScalarValue(mvScalarValue);

binaryComplement.Execute();