Losing resolution after transformation using imwarp

조회 수: 17 (최근 30일)
Jos Muller
Jos Muller 2023년 1월 5일
편집: Matt J 2023년 1월 5일
I'm working on a camera calibration through a series of pictures of a checkerboard. The original size of the images are 2048x2448. After transformation, the resulting corrected image with 'imwarp' is only 310x367. Although the transformation seems correct, the resolution seems very low to me and I'm wondering why the resolution dropped so significantly. The transformation I performing is some minor intrinsic/extrinsic corrections.
Here is the code used. The variable 'cameraParams' is obtained after successfully using the "camera calibration tool" from the "Computer Vision Toolbox v10.2". Both the raw image (.bmp) and the 'cameraParams.mat' are attached.
Thanks for the help.
[im_a, newOrigin] = undistortImage(imread(strcat(figlocation,fig_name)), cameraParams);
imagePoints = squeeze(cameraParams.ReprojectedPoints(:,:,end));
tf = fitgeotrans(imagePoints,cameraParams.WorldPoints,'projective');
[xf1,xf1_ref] = imwarp(im_a,tf,'cubic');
im_b=rot90(xf1);
figure;imshow(im_a);title('image')
figure;imshow(im_b);title('transformed image')

채택된 답변

Matt J
Matt J 2023년 1월 5일
load cameraParams
im0=imread('b8-12212022142637-2006.Bmp');
[im_a, newOrigin] = undistortImage(im0, cameraParams);
imagePoints = squeeze(cameraParams.ReprojectedPoints(:,:,end));
tf = fitgeotrans(imagePoints,cameraParams.WorldPoints,'projective');
[~,xf1_ref] = imwarp(im_a,tf,'cubic');
xf1_ref.ImageSize=flip(size(im_a));
[xf1,xf1_ref] = imwarp(im_a,tf,'cubic','OutputView',xf1_ref);
im_b=rot90(xf1);
figure;imshow(im_a);title('image')
figure;imshow(im_b);title('transformed image')
  댓글 수: 2
Jos Muller
Jos Muller 2023년 1월 5일
편집: Jos Muller 2023년 1월 5일
Thanks Matt,
Neat solution.
Sofar I understand from your awnser, imwarp default changes the imageSize of the projected image to 367x310. To prevent this, you first generate a 'imref2d' object where you manually change the image size. By then explicitly mention the 'outputview' parameter, 'imwrap' retains the image resolution. Is this correct?
However, aside the resolution, the projection from pixels to actual distances through worldpoints seems to be affected by this solution as well. In the projection I want the checkerboard to correspond to 20 mm distance (as in 'cameraParams.WorldPoints' mat-file. However, when measuring the distance in imtool(im_b), this now looks like 138 (mm?)
Best,
Jos
Matt J
Matt J 2023년 1월 5일
편집: Matt J 2023년 1월 5일
imtool() is assuming the pixel sizes are 1 mm. I'm not aware if there is a way to tell it that the actual pixel sizes are about 0.15 mm,
xf1_ref =
imref2d with properties:
XWorldLimits: [-76.6815 233.3185]
YWorldLimits: [-105.2473 261.7527]
ImageSize: [2448 2048]
PixelExtentInWorldX: 0.1514
PixelExtentInWorldY: 0.1499
ImageExtentInWorldX: 310
ImageExtentInWorldY: 367
XIntrinsicLimits: [0.5000 2.0485e+03]
YIntrinsicLimits: [0.5000 2.4485e+03]

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by