I would like to get some support on LDC tuning. How can I get better distortion correction using LDC LUT.
Input image size is 1280x960, output image size is the same. I want to do distortion correction using LDC LUT.
I have given a distortion function from lens vendors, HFOV>190°, VFOV>135° , focal length = 0.89 mm, pixel size of sensor = 3μm. I generated mesh lut file using the script below.
function ldc
gen_lut('/home/vvn/Documents/ldc_spec.txt', 3/1000, 1.78, 1280, 960, 640, 480, 4, 2);
end
% read the distortion specification table(angle and height)
function lut = read_spec(spec_file, pitch_in_mm)
lut0 = dlmread(spec_file);
theta = lut0(:,1)/180*pi;
lut = [theta, lut0(:,2)/pitch_in_mm];
end
% back map
function [h_d, v_d] = xyz2distorted(x, y, z, hc, vc, spec_file, pitch_in_mm)
xt = x-hc; yt = y-vc; zt = z*ones(size(xt));
[phi, r] = cart2pol(xt, yt);
theta = atan2(r, zt);
lut = read_spec(spec_file, pitch_in_mm);
r_d = interp1(lut(:,1), lut(:,2), theta);
[h_d, v_d] = pol2cart(phi, r_d);
h_d = h_d + hc; v_d = v_d + vc;
end
function [] = gen_lut(spec_file, pitch_in_mm, f_in_mm, W, H, hc, vc, s, m)
f = f_in_mm/pitch_in_mm;
[h_p, v_p] = meshgrid(0:W, 0:H);
[h_d, v_d] = xyz2distorted(h_p, v_p, f/s, hc, vc, spec_file, pitch_in_mm);
h_delta = round((h_d - h_p)*8);
v_delta = round((v_d - v_p)*8);
mh=h_delta(1:2^m:end, 1:2^m:end)';
mv=v_delta(1:2^m:end,1:2^m:end)';
dlmwrite('/home/vvn/Documents/ldc_mesh.txt', [mh(:), mv(:)], 'delimiter', ' ');
end
Origin image:
And then, I imported mesh lut file into dcc tool and used dcc tool to generate ldc table.
Dcc setting:
But I found output image is too bad.
Output image:
Appreciate your guidance here.