Absolute Threshold
1 개요
임계값을 이용하여 이미지를 이진화하는 알고리즘입니다.
2 알고리즘 상세 설명
Source | Threshold Value : 128 Range Value : 255 Out of Range Value : 0 |
|||||
---|---|---|---|---|---|---|
Greater | Greater Equal | Equal | Not Equal | Less Equal | Less | |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Absolute Threshold 알고리즘은 임계 조건에 따라 연산 결과가 참이면 Range Value로 결과 픽셀을 출력하고, 거짓이면 Out of Range Value로 결과 픽셀을 출력합니다.
위의 예시에서는 원본 이미지 값 128이 임계값 128과 같기 때문에 Greater Equal/Equal/Less Equal에서 참이므로 Range Value 255를 출력합니다. 그 외의 경우 거짓이므로 Out of Range Value 0을 출력합니다.
Range Value가 설정되지 않은 경우, 원본 이미지 포맷이 실수형인 경우 1로 설정되고, 아닌 경우에는 해당 포맷의 최댓값으로 설정됩니다. Out of Range Value가 설정되지 않은 경우, 원본 이미지 포맷이 실수형인 경우 0으로 설정되고, 아닌 경우에는 해당 포맷의 최솟값으로 설정됩니다.
CAbsoluteThreshold absoluteThreshold;
CFLImage fliSourceImage;
absoluteThreshold.SetSourceImage(fliSourceImage);
CMultiVar<int64_t> mvLogicalCondition;
mvLogicalCondition.PushBack((int64_t)(ELogicalCondition_Greater));
absoluteThreshold.SetLogicalCondition(mvLogicalCondition);
CMultiVar<double> mvThreshold1(128);
absoluteThreshold.SetThreshold(mvThreshold1);
CMultiVar<double> mvRange(255);
absoluteThreshold.SetRangeValue(mvRange);
CMultiVar<double> mvOutOfRange(0);
absoluteThreshold.SetOutOfRangeValue(mvOutOfRange);
absoluteThreshold.Execute();
Source | Threshold Condition : (Greater, Greater, Greater) Threshold Value : (128, 128, 128) Range Value : (255, 255, 255) Out of Range Value : (0, 0, 0) |
|
---|---|---|
And | Or | |
![]() |
![]() |
![]() |
이미지가 다중 채널인 경우, 각 채널들의 임계 조건에 따른 결과들을 사용자가 지정한 조건으로 논리 연산을 수행합니다. 위와 같이 논리 연산 결과가 참이면 Range Value로 결과 픽셀을 출력하고, 거짓이면 Out of Range Value로 결과를 출력합니다.
위의 예시에서는 하나의 채널이 임계값 128보다 크지 않은 126이기 때문에 And에서는 거짓이고, Or에서는 참이 되어 채널 논리 조건 연산에 따라 다른 결과를 출력합니다.
CAbsoluteThreshold absoluteThreshold;
CFLImage fliSourceImage;
absoluteThreshold.SetSourceImage(fliSourceImage);
CMultiVar<int64_t> mvLogicalCondition;
mvLogicalCondition.PushBack((int64_t)(ELogicalCondition_Greater));
mvLogicalCondition.PushBack((int64_t)(ELogicalCondition_Greater));
mvLogicalCondition.PushBack((int64_t)(ELogicalCondition_Greater));
absoluteThreshold.SetLogicalCondition(mvLogicalCondition);
absoluteThreshold.SetLogicalConditionOfChannels(ELogicalConditionOfChannels_And);
CMultiVar<double> mvThreshold1(128, 128, 128);
absoluteThreshold.SetThreshold(mvThreshold1);
CMultiVar<double> mvRange(255, 255, 255);
absoluteThreshold.SetRangeValue(mvRange);
CMultiVar<double> mvOutOfRange(0, 0, 0);
absoluteThreshold.SetOutOfRangeValue(mvOutOfRange);
absoluteThreshold.Execute();
Source | Threshold Condition1 : Greater Threshold Condition2 : Less Equal Threshold Value1 : 128 Threshold Value2 : 255 Range Value : 255 Out of Range Value : 0 |
|
---|---|---|
Dual And | Dual Or | |
![]() |
![]() |
![]() |
15.1.1과 15.1.2의 예시는 Threshold Mode가 Single인 경우이며, Dual 연산도 수행 가능합니다. Dual 연산의 경우 두 개의 임계 조건에 따른 연산을 수행합니다.
위의 예시에서 첫 번째 임계 조건 Greater에서 원본 이미지 값 128이 첫 번째 임계값 128보다 크지 않으므로 연산 결과가 거짓이고, 두 번째 임계 조건 Less Equal에서는 두 번째 임계값인 255 이하이므로 연산 결과가 참입니다. 따라서 Threshold Mode가 Dual And인 경우, 각 연산 결과의 And 연산에 의해 거짓이므로 Out of Range Value 0을 출력하고 Threshold Mode가 Dual Or인 경우, Or 연산에 의해 참이므로 Range Value 255를 출력합니다.
CAbsoluteThreshold absoluteThreshold;
CFLImage fliSourceImage;
absoluteThreshold.SetSourceImage(fliSourceImage);
CMultiVar<int64_t> mvLogicalCondition;
mvLogicalCondition.PushBack((int64_t)(ELogicalCondition_Greater));
absoluteThreshold.SetLogicalCondition(mvLogicalCondition);
CMultiVar<int64_t> mvLogicalCondition2;
mvLogicalCondition2.PushBack((int64_t)(ELogicalCondition_LessEqual));
absoluteThreshold.SetLogicalCondition(mvLogicalCondition2, EThresholdIndex_Second);
absoluteThreshold.SetThresholdMode(EThresholdMode_Dual_And);
CMultiVar<double> mvRange(255);
absoluteThreshold.SetRangeValue(mvRange);
CMultiVar<double> mvOutOfRange(0);
absoluteThreshold.SetOutOfRangeValue(mvOutOfRange);
absoluteThreshold.Execute();
3 파라미터 설정 및 사용 방법
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetThresholdMode | ImageProcessing::EThresholdMode | eThresholdMode | IN | Threshold Mode 설정값 |
Threshold Mode를 설정합니다. Single을 선택하면 하나의 임계 조건에 대한 연산을 진행합니다. Dual And를 선택하면 두 임계 조건 모두 만족 시 최종 결과가 참이 됩니다. Dual Or를 선택하면 두 임계 조건 중 하나라도 만족 시 최종 결과가 참이 됩니다.
eThresholdMode
- Default Value: EThresholdMode_Single, Recommended Value: EThresholdMode_Single
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetLogicalConditionOfChannels | ImageProcessing::ELogicalConditionOfChannels | eLogicalConditionOfChannels | IN | 각 채널의 결과에 대한 논리 연산 방식 |
채널별 결과들을 어떤 논리 연산 방식으로 처리할지 설정합니다. And를 선택하면 모든 채널의 연산 결과가 참인 경우 최종 결과가 참이 되고, Or를 선택하면 하나의 채널이라도 연산 결과가 참이라면 최종 결과가 참이 됩니다.
eCondition
- Default Value: ELogicalConditionOfChannels_And, Recommended Value: ELogicalConditionOfChannels_And
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
EnableAbsoluteMode | bool | bAbsoluteMode | IN | 임계값을 절대값으로 처리하는 모드 설정 |
부호가 있는 이미지에 대해 임계값을 절대값으로 처리하는 모드를 설정합니다.
bAbsoluteMode
- Default Value: false, Recommended Value: false
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetThreshold | double | f64Threshold | IN | 임계값 |
ImageProcessing::EThresholdIndex | eIndex | IN | 임계값 Index |
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetThreshold | CMultiVar<double> | mvThreshold | IN | 임계값 |
EThresholdIndex | eIndex | IN | 임계값 Index |
설정한 Threshold Index에 따라 첫 번째 또는 두 번째 임계값을 설정합니다. Thrshold Index를 First로 설정 시 첫 번째 임계값을 설정하고, Second 설정 시 두 번째 임계값을 설정합니다.
eIndex
- Default Value: EThresholdIndex_First, Recommended Value: EThresholdIndex_First
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetThreshold | CMultiVar<double> | mvThreshold1 | IN | 첫 번째 임계값 |
CMultiVar<double> | mvThreshold2 | IN | 두 번째 임계값 |
첫 번째, 두 번째 임계값을 설정합니다. mvThreshold1에 첫 번째 임계값을 설정하고, mvThreshold2에 두 번째 임계값을 설정합니다.
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetRangeValue | CMultiVar<double> | mvRangeValue | IN | 연산 결과가 참인 경우, 이진화 출력값 |
연산 결과가 참인 경우 출력할 Range 값을 설정합니다.
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetOutOfRangeValue | CMultiVar<double> | mvOutOfRangeValue | IN | 연산 결과가 거짓인 경우, 이진화 출력값 |
연산 결과가 거짓인 경우 출력할 Out of Range 값을 설정합니다.
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetLogicalCondition | Base::ELogicalCondition | eThresholdCondition | IN | 논리 조건 설정값 |
ImageProcessing::EThresholdIndex | eIndex | IN | 논리 조건 Index |
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetLogicalCondition | int64_t | i64ThresholdCondition | IN | 논리 조건 설정값 |
ImageProcessing::EThresholdIndex | eIndex | IN | 논리 조건 Index |
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetLogicalCondition | CMultiVar<int64_t> | mvThresholdCondition | IN | 논리 조건 설정값 |
ImageProcessing::EThresholdIndex | eIndex | IN | 논리 조건 Index |
설정한 Threshold Index에 따라 첫 번째 또는 두 번째 논리 조건을 설정합니다. 논리 조건은 Greater(큼), Greater Equal(크거나 같음), Equal(같음), Not Equal(같지 않음), Less Equal(작거나 같음), Less(작음)으로 설정 가능합니다.
eIndex
- Default Value: EThresholdIndex_First, Recommended Value: EThresholdIndex_First
멤버함수 | 파라미터 | 설 명 | ||
---|---|---|---|---|
SetLogicalCondition | CMultiVar<int64_t> | mvThresholdCondition1 | IN | 첫 번째 논리 조건 설정값 |
CMultiVar<int64_t> | mvThresholdCondition2 | IN | 두 번째 논리 조건 설정값 |
첫 번째, 두 번째 논리 조건을 설정합니다. mvThresholdCondition1에 첫 번째 논리 조건을 설정하고, mvThresholdCondition2에 두 번째 논리 조건을 설정합니다.