我试图改进OpenCV lanczos插值算法的性能,将同形变换应用于天文图像,因为它很容易在某些图像中围绕星体振铃。我的方法是两次应用同形,一次使用lanczos,一次使用双线性滤波,它不受振铃的影响,但在保持细节方面表现不佳。然后,我使用双线性内插输出作为引导图像,并将lanczos插值输出夹紧到指南,如果其低于给定的百分比。我有工作代码(以下),但有两个问题:
,
。
warpPerspective(in, out, H, Size(target_rx, target_ry), interpolation, BORDER_TRANSPARENT);
if (interpolation == OPENCV_LANCZOS4) {
int count = 0;
// factor sets how big an undershoot can be tolerated
double factor = 0.75;
// Create guide image
warpPerspective(in, guide, H, Size(target_rx, target_ry), OPENCV_LINEAR, BORDER_TRANSPARENT);
// Compare the two, replace out pixels with guide pixels if too far out
for (int i = 0 ; i < out.rows ; i++) {
const double* outi = out.ptr<double>(i);
const double* guidei = guide.ptr<double>(i);
for (int j = 0; j < out.cols ; j++) {
if (outi[j] < guidei[j] * factor) {
out.at<double>(i, j) = guidei[j];
count++;
}
}
}
}发布于 2022-10-04 18:11:32
克里斯多夫·拉克维茨( Christoph Rackwitz )给出的答案非常简单:
compare(out, (guide * factor), mask, CMP_LT);
guide.copyTo(out, mask);谢谢:)
https://stackoverflow.com/questions/73946947
复制相似问题