how to convert a project video mosaicking to project mosaic of two images

조회 수: 1 (최근 30일)
remos remos
remos remos 2014년 5월 21일
댓글: Image Analyst 2014년 8월 12일
hi, I am newbie in matlab and image processing This tutorial shows how to create a panorama from a video http://www.mathworks.com/help/vision/examples/video-mosaicking.html I want create a panorama for only two images using this code thank you in advance
  댓글 수: 2
Alex Taylor
Alex Taylor 2014년 5월 21일
I would love to try to help you, but as I've asked repeatedly in your last posts, I need two separate image files. The images you are actually trying to form a mosaic from. I need this data to tune the registration algorithm I will use, and to try to decide which algorithm to use.
Without these images, I could at best provide you code that succeeds at registering the two images I would choose, but might not work very well with your data.
I'm really trying to be helpful here...
Image Analyst
Image Analyst 2014년 8월 12일
Alex, I still think it could be instructive for others if you could take two demo images , with some overlap, translation, rotation, and possibly magnification differences and seamlessly stitch them together into a panorama. As a rule of thumb, about what percentage of overlap is needed for a good alignment?

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

답변 (1개)

remos remos
remos remos 2014년 5월 21일
편집: remos remos 2014년 5월 21일
if true
[w, h] = deal(680, 400); % Size of the mosaic
[x0, y0] = deal(-5, -60); % Upper-left corner of the mosaic
xLim = [0.5, w+0.5] + x0;
yLim = [0.5, h+0.5] + y0;
outputView = imref2d([h,w], xLim, yLim);
hsrc = vision.VideoFileReader('vipmosaicking.avi', 'ImageColorSpace','RGB', 'PlayCount', 1);
%
halphablender = vision.AlphaBlender('Operation', 'Binary mask', 'MaskSource', 'Input port');
%
hVideo1 = vision.VideoPlayer('Name', 'Corners');
hVideo1.Position(1) = hVideo1.Position(1) - 350;
%
hVideo2 = vision.VideoPlayer('Name', 'Mosaic');
hVideo2.Position(1) = hVideo1.Position(1) + 400;
hVideo2.Position([3 4]) = [750 500];
%
points = cornerPoints(zeros(0, 2));
features = binaryFeatures(zeros([0 64], 'uint8'));
failedToMatchPoints = true; % A new mosaic will be created if
% failedToMatchPoints is true
%
while ~isDone(hsrc)
% Save the points and features computed from the previous image
pointsPrev = points;
featuresPrev = features;
% To speed up mosaicking, select and process every 5th image
for i = 1:5
rgb = step(hsrc);
if isDone(hsrc)
break;
end
end
% Convert the image from RGB to intensity.
I = rgb2gray(rgb);
% Detect corners in the image
corners = detectFASTFeatures(I);
% Extract FREAK feature vectors for the corners
[features, points] = extractFeatures(I, corners);
% Match features computed from the current and the previous images
indexPairs = matchFeatures(features, featuresPrev);
% Check if there are enough corresponding points in the current and the
% previous images
if size(indexPairs, 1) > 2
matchedPoints = points(indexPairs(:, 1), :);
matchedPointsPrev = pointsPrev(indexPairs(:, 2), :);
% Find corresponding locations in the current and the previous
% images, and compute a geometric transformation from the
% corresponding locations
[tform, ~, ~, failedToMatchPoints] = estimateGeometricTransform(...
matchedPoints, matchedPointsPrev, 'affine');
end
if failedToMatchPoints
% If the current image does not match the previous one, reset the
% transformation and the mosaic image
xtform = eye(3);
mosaic = zeros(h, w, 3, 'single');
else
% If the current image matches with the previous one, compute the
% transformation for mapping the current image onto the mosaic
% image
xtform = xtform * tform.T;
end
% Display the current image and the corner points
cornerImage = insertMarker(rgb, corners.Location, 'Color', 'red');
step(hVideo1, cornerImage);
% Creat a mask which specifies the region of the transformed image.
mask = imwarp(ones(size(I)), affine2d(xtform), 'OutputView', outputView) >= 1;
% Warp the current image onto the mosaic image
transformedImage = imwarp(rgb, affine2d(xtform), 'OutputView', outputView);
mosaic = step(halphablender, mosaic, transformedImage, mask);
step(hVideo2, mosaic);
end
%
release(hsrc);
end
  댓글 수: 1
Image Analyst
Image Analyst 2014년 8월 12일
Did you see Alex's post? He asked you for the two images so he could try something, but you did not attach them.

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

Community Treasure Hunt

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

Start Hunting!

Translated by