How to use control Points in Image processing?
Mostrar comentarios más antiguos
- _ _At first, I used "normxcorr2" to find a same part of an image in another one, but in some cases this method failed to findingRelated code is:
f=100;
S=imcrop(Image1,[f*2 f*2 f f]);
L = bwlabel(S);
s = regionprops(L,'PixelIdxList');
% Initialize vector containing max values.
max_value = zeros(numel(s), 1);
% Loop over each labeled object, grabbing the gray scale pixel values using
% PixelIdxList and computing their maximum.
for k = 1:numel(s)
max_value(k) = max(S(s(k).PixelIdxList));
end
% Show all the maximum values as a bar chart.
bright_objects = find(max_value > 100);
s=ismember(L, bright_objects);
c = normxcorr2(s,Image2);
[ypeak, xpeak] = find(c==max(c(:)));
yoffSet = ypeak-size(S,1)
xoffSet = xpeak-size(S,2)
hFig = figure;
hAx = axes;
imshow(Image2,'Parent', hAx);
imrect(hAx, [xoffSet+1, yoffSet+1, size(S,2), size(S,1)]);
S2=imcrop(Image2,[max(xoffSet)+1 max(yoffSet)+1 size(S,2)-1 size(S,1)-1]);
And it's work correctly(it has been shown in below image).

- so I have to use control points to improve this approach. Now i want to use control points for the same way, but the main problem that exist is I didn't know how to determine coordinate of control points in original Image and then display them in it by code ?! note that "cpselect" command select the control points by hand! please look at this part of code:
scale = 1;
J = imresize(Image1, scale); % Try varying the scale factor.
theta = 90;
distorted = imrotate(J,theta); % Try varying the angle, theta.
ptsOriginal = detectSURFFeatures(Image2);
ptsDistorted = detectSURFFeatures(distorted);
[featuresOriginal, validPtsOriginal] = extractFeatures(Image2, ptsOriginal);
[featuresDistorted, validPtsDistorted] = extractFeatures(distorted, ptsDistorted);
indexPairs = matchFeatures(featuresOriginal, featuresDistorted);
matchedOriginal = validPtsOriginal(indexPairs(:,1));
matchedDistorted = validPtsDistorted(indexPairs(:,2));
x1 = matchedDistorted.Location(1,1)
y1 = matchedDistorted.Location(1,2)
S22=imcrop(Image2,[x1 y1 size(S,2)-1 size(S,1)-1]);
Indead by using this code, the control points coordinate determined but I want to display matched area in Image2. how can I find coordinate to crop this founded area?I think [x1,y1] isn't true and problem is here. Do you have any idea?
And it acts wrong(it has been shown in below image).

1 comentario
Shahab B
el 27 de Sept. de 2016
Respuestas (0)
Categorías
Más información sobre Image Registration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!