Thin Plate Spline Warping
1 개요
Thin Plate Spline Warping 은 설정 된 제어 점들을 이용하여 Thin Plate spline interpolation 방식을 통해 이미지를 변환하는 알고리즘 입니다.
2 알고리즘 상세 설명
Thin Plate Spline Warping 알고리즘은 주어진 제어 점들의 Mapping 함수를 통해 유연한 곡선의 비선형 변환을 생성합니다.
Minimize :
Etps,smooth(f)=i=1∑Kyi−f(xi)2+λ∬[fx1x12+2fx1x2+fx2x22]dx1dx2
- K : Corresponding control points (knots)
- f : Mapping function of {xi}→{yi}
| Source |
Source points |
Dest points |
Result |
 |
 |
 |
 |
Fig. 알고리즘 수행 결과
3 예제 코드
CThinPlateSplineWarping thinPlateSplineWarping;
CFLImage fliSourceImage;
CFLImage fliDestinationImage;
thinPlateSplineWarping.SetSourceImage(fliSourceImage);
thinPlateSplineWarping.SetDestinationImage(fliDestinationImage);
CFLPointArray flpaSource;
flpaSource.PushBack(CFLPoint<double>(0,0));
flpaSource.PushBack(CFLPoint<double>(100.0, 100.0));
CFLPointArray flpaDestination;
flpaDestination.PushBack(CFLPoint<double>(10.0,10.0));
flpaDestination.PushBack(CFLPoint<double>(90.0, 90.0));
thinPlateSplineWarping.SetCalibrationPointArray(flpaSource, flpaDestination);
thinPlateSplineWarping.Calibrate();
thinPlateSplineWarping.SetInterpolationMethod(EInterpolationMethod_Bicubic);
thinPlateSplineWarping.Execute();
CThinPlateSplineWarping thinPlateSplineWarping = new CThinPlateSplineWarping();
CFLImage fliSourceImage = new CFLImage();
CFLImage fliDestinationImage = new CFLImage();
thinPlateSplineWarping.SetSourceImage(ref fliSourceImage);
thinPlateSplineWarping.SetDestinationImage(ref fliDestinationImage);
CFLPointArray flpaSource = new CFLPointArray();
flpaSource.PushBack(new CFLPoint<double>(0,0));
flpaSource.PushBack(new CFLPoint<double>(100.0, 100.0));
CFLPointArray flpaDestination = new CFLPointArray();
flpaDestination.PushBack(new CFLPoint<double>(10.0,10.0));
flpaDestination.PushBack(new CFLPoint<double>(90.0, 90.0));
thinPlateSplineWarping.SetCalibrationPointArray(flpaSource, flpaDestination);
thinPlateSplineWarping.Calibrate();
thinPlateSplineWarping.SetInterpolationMethod(EInterpolationMethod.Bicubic);
thinPlateSplineWarping.Execute();
thinPlateSplineWarping = CThinPlateSplineWarping()
fliSourceImage = CFLImage()
fliDestinationImage = CFLImage()
thinPlateSplineWarping.SetSourceImage(fliSourceImage)
thinPlateSplineWarping.SetDestinationImage(fliDestinationImage)
flpaSource = CFLPointArray()
flpaSource.PushBack(CFLPoint[Double](0,0))
flpaSource.PushBack(CFLPoint[Double](100.0, 100.0))
flpaDestination = CFLPointArray()
flpaDestination.PushBack(CFLPoint[Double](10.0,10.0))
flpaDestination.PushBack(CFLPoint[Double](90.0, 90.0))
thinPlateSplineWarping.SetCalibrationPointArray(flpaSource, flpaDestination)
thinPlateSplineWarping.Calibrate()
thinPlateSplineWarping.SetInterpolationMethod(EInterpolationMethod.Bicubic)
thinPlateSplineWarping.Execute()
4 파라미터 설정 및 사용 방법
thinPlateSplineWarping.SetInterpolationMethod(eMethod);
thinPlateSplineWarping.SetInterpolationMethod(eMethod);
thinPlateSplineWarping.SetInterpolationMethod(eMethod)
eMethod : 보간 방식을 설정합니다. EInterpolationMethod의 Enum 옵션을 지원하며 기본값은 Bilinear입니다.
thinPlateSplineWarping.SetCalibrationPointArray(flpaSource, flpaDestination);
thinPlateSplineWarping.SetCalibrationPointArray(flpaSource, flpaDestination);
thinPlateSplineWarping.SetCalibrationPointArray(flpaSource, flpaDestination)
flpaSource : Source Control 포인트들의 배열입니다. double 타입의 CFLPoint로 구성되어 있으며, 보정하기 전 좌표가 이에 해당됩니다.
flpaDestination : Target Control 포인트들의 배열입니다. double 타입의 CFLPoint로 구성되어 있으며, 보정 결과에 해당하는 좌표가 이에 해당됩니다. Source Control 포인트 배열과 순서가 일치 해야합니다.
thinPlateSplineWarping.EnableMemorySavingMode(bEnable);
thinPlateSplineWarping.EnableMemorySavingMode(bEnable);
thinPlateSplineWarping.EnableMemorySavingMode(bEnable)
bEnable : Warping 연산을 수행할 때 메모리 비용 절감에 대한 옵션을 선택할 수 있습니다. 해당 옵션을 사용하지 않는 경우, 더 많은 메모리를 소모하여 더 빠른 연산 수행 속도를 기대할 수 있습니다. 기본값은 true입니다.
thinPlateSplineWarping.Calibrate();
thinPlateSplineWarping.Calibrate();
thinPlateSplineWarping.Calibrate()
- 설정된 정보를 바탕으로 Warping을 수행하기 위한 Mapping 함수를 계산합니다.
thinPlateSplineWarping.Save(wstrPath);
thinPlateSplineWarping.Save(wstrPath);
thinPlateSplineWarping.Save(wstrPath)
wstrPath : Calibration 정보를 저장할 수 있습니다 wchar_t 형식의 CFLString으로 입력할 수 있습니다.
thinPlateSplineWarping.Load(wstrPath);
thinPlateSplineWarping.Load(wstrPath);
thinPlateSplineWarping.Load(wstrPath)
wstrPath : 저장된 Calibration 정보를 불러 올 수 있습니다 wchar_t 형식의 CFLString으로 입력할 수 있습니다.