[NewPicture1_img] = registerImages(Picture1_img,Capture_img)
NewPicture1_img =
FixedMatchedFeatures: [220×1 SURFPoints]
MovingMatchedFeatures: [220×1 SURFPoints]
Transformation: [1×1 projective2d]
RegisteredImage: [627×663×3 uint8]
SpatialRefObj: [1×1 imref2d]
imshow(NewPicture1_img.RegisteredImage)
Picture1_img=NewPicture1_img.RegisteredImage;
imshow(Picture1_img(:,:,1))
imshow(Picture1_img(:,:,1)>225&Picture1_img(:,:,2)==0)
imshow(Capture_img.*uint8(Picture1_img(:,:,1)>225&Picture1_img(:,:,2)==0))
function [MOVINGREG] = registerImages(MOVING,FIXED)
MOVING = im2gray(MOVING);
fixedRefObj = imref2d(size(FIXED));
movingRefObj = imref2d(size(MOVING));
fixedPoints = detectSURFFeatures(FIXED,'MetricThreshold',750.000000,'NumOctaves',3,'NumScaleLevels',5);
movingPoints = detectSURFFeatures(MOVING,'MetricThreshold',750.000000,'NumOctaves',3,'NumScaleLevels',5);
[fixedFeatures,fixedValidPoints] = extractFeatures(FIXED,fixedPoints,'Upright',false);
[movingFeatures,movingValidPoints] = extractFeatures(MOVING,movingPoints,'Upright',false);
indexPairs = matchFeatures(fixedFeatures,movingFeatures,'MatchThreshold',50.000000,'MaxRatio',0.500000);
fixedMatchedPoints = fixedValidPoints(indexPairs(:,1));
movingMatchedPoints = movingValidPoints(indexPairs(:,2));
MOVINGREG.FixedMatchedFeatures = fixedMatchedPoints;
MOVINGREG.MovingMatchedFeatures = movingMatchedPoints;
tform = estimateGeometricTransform2D(movingMatchedPoints,fixedMatchedPoints,'projective');
MOVINGREG.Transformation = tform;
MOVINGREG.RegisteredImage = imwarp(MOVINGRGB, movingRefObj, tform, 'OutputView', fixedRefObj, 'SmoothEdges', true);
MOVINGREG.SpatialRefObj = fixedRefObj;
CVTStatus = license('test','Video_and_Image_Blockset');
error(message('images:imageRegistration:CVTRequired'));