は、厳密に言えば、これはIMTRANSFORM変換画像が射影で整流することを可能にすることができる
を行うことができないが、これは平面上の画像位置におけるオブジェクトと仮定表面。これは、2つの異なる角度からチェス盤を撮るようなものです。下の画像を参照してください。
それは平面であるので、チェス盤を整流することができる唯一の理由です。シリンダーは3Dであるため、ポイントを修正することはできません。
あなたの代わりに
を行うことができますどのようなそれらを一緒にバックステッチ、その後、各サブイメージを是正、シリンダーからサブイメージを抽出することが可能です。
例
まず、赤色ドットその間の点を選択することにより、サブイメージを取得する(画像上にあるoを赤色で示します)。下のものは任意であることに注意してください。次に、それらの赤い点が(緑色のx)として表示されるようにする場所を選択します。
次に、各サブ画像を整流します。赤い点は緑のxの上にあることに注意してください。
第一副画像
第2のサブ画像
第3のサブ画像
今stit画像を一緒に戻してください。今、すべての赤い点が同じ行にあることに注意してください。
close all; clear all; clc;
%Read image
im1 = imread('crCTbm.jpg');
%Location of your red dots
x1 = [49; 106; 178; 234];
y1 = [115 116 126 136];
%Red dots will be aligned on yline in the final image
yline = y1(1);
%Initialize cells
subim = cell(1,length(x1)-1); %Tracks parsed images
Transform = cell(1,length(x1)-1); %Projective transform for each subim
RectifiedIm = cell(1,length(x1)-1); %Rectified images
%Initialize boundaries of image (Due to warping, sometimes the images can
%stretch beyond the border of the original image)
xdataout = [1,1]; ydataout = [1,1];
t1 = figure; imshow(im1);
for ii = 1:length(x1)-1
%Extract a subimage defined by your red dots
tim = zeros(size(im1));
tim(:,x1(ii):x1(ii+1),:) = im1(:,x1(ii):x1(ii+1),:);
subim{ii} = tim;
%Define four points in the original image
originalpoints{ii} = [x1(ii),y1(ii);... %Red Dot
x1(ii+1),y1(ii+1);... %Red Dot
x1(ii),y1(ii)+50;... %Arbitrary point
x1(ii+1),y1(ii)+50]; %Arbitrary point
%Define where there four points should lie in the rectified image
correctedpoints{ii} = [x1(ii),yline;... %Red dot should stay on the same x-coordinate, but y-coordinate is shited to the yline
x1(ii+1),yline;... %Red dot should stay on the same x-coordinate, but y-coordinate is shited to the yline
x1(ii),yline+50;... %Rectilinear point
x1(ii+1),yline+50]; %Rectilinear point
%Plot the original and corrected coordinates on the image
figure(t1); hold on;
plot(originalpoints{ii}(:,1),originalpoints{ii}(:,2),'ro');
plot(correctedpoints{ii}(:,1),correctedpoints{ii}(:,2),'gx');
legend('Original Points','correctedpoints{ii}');
%Sometimes the rectified image extends beyond the borders of the
%original boundary. This finds the worst case scenario for warping and
%sets the boundaries to that
Transform{ii} = maketform('projective',originalpoints{ii},correctedpoints{ii});
[~,xdataim2t,ydataim2t]=imtransform(im1,Transform{ii});
% now xdataim2t and ydataim2t store the bounds of the transformed im2
xdataout=[min([1,xdataim2t(1),xdataout(1)]) max([size(im1,2),xdataim2t(2),xdataout(2)])];
ydataout=[min([1,ydataim2t(1),xdataout(1)]) max([size(im1,1),ydataim2t(2),xdataout(2)])];
end
%Rectify the images
rectifiedx = floor(xdataout(1)):ceil(xdataout(2))+1; %x-coordinates of new image
rectifiedy = floor(ydataout(1)):ceil(ydataout(2))+1; %y-coordinates of new image
for ii = 1:length(x1)-1
RectifiedIm{ii}=imtransform(subim{ii},Transform{ii},'XData',xdataout,'YData',ydataout);
figure; image(rectifiedx,rectifiedy,uint8(RectifiedIm{ii})); hold on;
plot(originalpoints{ii}(:,1),originalpoints{ii}(:,2),'ro');
plot(correctedpoints{ii}(:,1),correctedpoints{ii}(:,2),'gx');
legend('Original Points','Rectified Points');
end
%Stitch the subimages together
finalim = zeros(size(RectifiedIm{1}));
for ii = 1:length(RectifiedIm)
finalim = max(double(finalim),double(RectifiedIm{ii}));
end
figure; imshow(uint8(finalim));
EDIT:
あなただけ1Dにポイントを合わせる気にする場合は、エピポーララインに沿ってそれらを揃えることも可能です。
"imtransformでいくつかのアプローチを試みましたが、うまくいかないようです。"私はいつも驚いています...エラーを起こしたり、死のブルースクリーンを引き起こしたり、あるいはコンピュータが100万個で完全に爆発しても機能しません。知るか。それはちょうど "doesnt仕事" –