How can I align an image according to another image?
Show older comments
I am trying to align an image according to a base image and according to the position of 2 circles on the left of each page.
The code I have so far is listed below but the only thing I have a problem with is how to use imtransfrom function to register the image.
Accepted Answer
More Answers (1)
[LI, numI] = bwlabel( imfill(BWIremove,'holes') );
[LJ, numJ] = bwlabel( imfill(BWJremove,'holes') );
centroidsI = regionprops(LI,'Centroid');
centroidsJ = regionprops(LJ,'Centroid');
% Create a transformation structure for an affine % transformation.
cI=vertcat(centroidsI.Centroid);
cJ=vertcat(centroidsJ.Centroid);
S=absor(cJ.', cI.');
t_concord=maketform('affine', S.M(1:2,:).');
registered = imtransform(IMJ,t_concord,....);
Because you're only using 2 landmarks to perform the registration, the alignment will probably not be as perfect as with imregister, although as I've said, I have my doubts about how well imregister would work across a larger population of questionnaires.
There are things you could do to improve the tilt angle estimate though, like find more landmarks, or use regionprops(...,'Orientation') on the answer boxes.
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!