>> demoASIFT Error using disp Too many output arguments. Error in demoASIFT (line 105) [ HrLPointsTmp1 ] = harrislpls( imgSimulated, TypeOfNBHOOD, NBHOOD, TypeOfCornerDetector, BorderDistanceMatrix, ThreshType, Harris

sir kindly please help me to rectify this coding sir. i m getting this error in ASIFT which i have downloaded from matlab file exchange.
">> demoASIFT
Error using disp
Too many output arguments.
Error in demoASIFT (line 105)
[ HrLPointsTmp1 ] = harrislpls( imgSimulated, TypeOfNBHOOD, NBHOOD, TypeOfCornerDetector,
BorderDistanceMatrix, ThreshType, HarrisThresh, k, Dilate, radius, sigma_nmbr, disp, SwitchWaitbars );
"
% assumption, that we have img1 and img2.
img1 = imread('ORIGINAL1.jpg');
img2 = imread('FAKE.1jpg.jpg');
if ndims(img1) == 3
img1gr = rgb2gray( img1 );
else
img1gr = img1;
end
if ndims(img2) == 3
img2gr = rgb2gray( img2 );
else
img2gr = img2;
end
[ m1, n1 ] = size( img1gr );
[ m2, n2 ] = size( img2gr );
%-------------------- Parameters -------------------%
SwitchWaitbars = 'off'; % 'off'/'on'
%--------------- Descriptors 4 FP ------------------%
TypeOfFP = 'Aff'; % 'Aff'/'HL'
TypeOfDescriptor = 'SIFT'; % there is possibility to add diferent type of descr., however I've implemented only SIFT.
NOfWindows = 4; % near each FP will be taken NOfWindows^2 of windows of size 4x4
AngleBinDescript = 45; % degrees
ThreshDescript = 0.2;
FactorDescript = 1.5;
StepSampleFunction = @(x) sqrt(1+x^2);
%-------------------- 'ASIFT' ----------------------%
TiltVectorRange = sqrt(2).^([ 0 1 2 3 4 ]); % also can be taken (0, 3 - 5)
StepAngleFunction = @(x) 72/x; % 72/x
TypeOfViewSimulation = 'both'; % 'first'/'second'/'both'
% which image views need to simulate
BlureTilt = 'no'; % 'yes'/'no'
BlureSigmaFunction = @(x) sqrt( x^2 - 1 ); % depends on tilt value
%--------------------- Harris ----------------------%
TypeOfCornerDetector = 'HarmonicMean'; % 'Harris'/'HarmonicMean'
TypeOfNBHOOD = 'const'; % 'const'/'dif'. 'dif' - depends on scale
NBHOOD = ones(3); % scalar or binar matrix, specifying neighberhood
BorderDistance = 3*NOfWindows;
ThreshType = 'const'; % 'const'/'percent'
HarrisThresh = 10; % in case of 'HarmonicMean', thresh ~ 10, Harris ~ 1000
k = 0.055; % parameter for Harris function
Dilate = 'no'; % 'yes'/'no'
radius = 2;
sigma_nmbr = 3;
dispMatches = 0; % 0/1
%--------------- Main Orientation -----------------%
ThreshMainOrient = 0.8;
FactorMainOrient = 1.5;
AngleBinMainOrient = 10;
TypeOfMainOrient = 'some'; % 'one'/'some'. 'one' - for each FP take only one Main Orientation
% ( take it, if this orient. is the only one bigger then ThreshMainOrient % of it's value )
% 'some' - take all orientations, that bigger then thresh, described above.
%----------------- Matching FPs -------------------%
TypeOfSearch = 'determ'; %'determ' 1/2, 'kmeans','kNN', 'ANN', for not big data preferable 'determ' 2,
% 'kmeans' - just for experiment.
HelpScalarOrVector = 2;
TypeOfMatchThresh = 'first/second&first'; % 'first' / 'first/second' / 'first/second&first'
ThreshFS = 0.78; % thresh for first/second ( 0.5 - ~0.8 )
% need to worry that, if there is a big difference in viewpoints between
% images, then take ~0.55 - 0.61, else can be taken ~0.75 - 0.8
ThreshF = 0.5; % thresh for first ( 0.33 - 0.55 )
%--------------------------------------------------------------------%
%----------- Simulating views for ASIFT --------------%
if strcmp( TypeOfViewSimulation, 'first' ) || strcmp( TypeOfViewSimulation, 'both' )
cnt1 = 1;
DescriptHrLPoints1 = {};
HrLOrntPoints1 = {};
img1Orig = img1gr;
for t = TiltVectorRange
DeltaPhi = StepAngleFunction( t );
for phi = 0:DeltaPhi:(180-eps)
phiAngle = deg2rad( phi );
% defining tilt and longitude affin simulation matrix
T = zeros( 3 );
T(3,3)=1;
Tilt = eye(2);
Tilt(1) = t;
R = [ cos(phiAngle) -sin(phiAngle); sin(phiAngle) cos(phiAngle) ];
Aff = Tilt*R;
T( 1:2, 1:2 ) = Aff';
Tf = maketform('affine',T); % affine transformation for view-simulation
if strcmp(BlureTilt, 'yes')
sigma = BlureSigmaFunction( t );
if sigma > 0
g = fspecial( 'gaussian', [ 1, round( 6*sigma ) + 1 ], sigma );
img1gr = imfilter( img1Orig, g, 'same' );
else
img1gr = img1Orig;
end
else
img1gr = img1Orig;
end
BorderDistanceMatrix = zeros( m1, n1 );
BorderDistanceMatrix( (BorderDistance + 1):(m1 - BorderDistance), (BorderDistance + 1):(n1 - BorderDistance) ) = 1;
[ imgSimulated, xdata, ydata ] = imtransform( img1gr, Tf );
BorderDistanceMatrix = imtransform( BorderDistanceMatrix, Tf, 'xdata', xdata, 'ydata', ydata );
%- Finding FP and they char. scale (Harris-Laplace) -%
[ HrLPointsTmp1 ] = harrislpls( imgSimulated, TypeOfNBHOOD, NBHOOD, TypeOfCornerDetector, BorderDistanceMatrix, ThreshType, HarrisThresh, k, Dilate, radius, sigma_nmbr, disp, SwitchWaitbars );
%----------- Finding Main Orientation -------------%
[ HrLOrntPointsTmp1 ] = mainOrient( HrLPointsTmp1, imgSimulated, ThreshMainOrient, FactorMainOrient, AngleBinMainOrient, TypeOfMainOrient, SwitchWaitbars );
%------------------ Descripting -------------------%
[ DescriptHrLPointsTmp1 ] = descriptFPoints( HrLOrntPointsTmp1, imgSimulated, TypeOfDescriptor, NOfWindows, StepSampleFunction, AngleBinDescript, ThreshDescript, FactorDescript, SwitchWaitbars );
%----- Converting FP coordinates to original ------%
% back to coordinates, before shift for image coord. ( xdata(1) -> 1, ydata(1) -> 1 )
HrLOrntPointsTmp1( :, [ 2 5 ] ) = HrLOrntPointsTmp1( :, [ 2 5 ] ) - 1 + xdata(1);
HrLOrntPointsTmp1( :, [ 1 4 ] ) = HrLOrntPointsTmp1( :, [ 1 4 ] ) - 1 + ydata(1);
% back to original image coordinates
tmp = tforminv( Tf, HrLOrntPointsTmp1( :, 5 ), HrLOrntPointsTmp1( :, 4 ));
HrLOrntPointsTmp1( :, 2 ) = round(tmp(:,1)); HrLOrntPointsTmp1( :, 1 ) = round(tmp(:,2));
HrLOrntPointsTmp1( :, 1 ) = max( HrLOrntPointsTmp1( :, 1 ), 1 ); HrLOrntPointsTmp1( :, 1 ) = min( HrLOrntPointsTmp1( :, 1 ), m1 );
HrLOrntPointsTmp1( :, 2 ) = max( HrLOrntPointsTmp1( :, 2 ), 1 ); HrLOrntPointsTmp1( :, 2 ) = min( HrLOrntPointsTmp1( :, 2 ), n1 );
HrLOrntPointsTmp1( :, 5 ) = tmp(:,1); HrLOrntPointsTmp1( :, 4 ) = tmp(:,2);
% adding FP to all FP, that were founded before
DescriptHrLPoints1{cnt1} = DescriptHrLPointsTmp1;
HrLOrntPoints1{cnt1} = HrLOrntPointsTmp1;
cnt1 = cnt1 + 1;
end
end
else
[ HrLPoints1 ] = harrislpls( img1gr, TypeOfNBHOOD, NBHOOD, TypeOfCornerDetector, BorderDistance, ThreshType, HarrisThresh, k, Dilate, radius, sigma_nmbr, disp, SwitchWaitbars );
%----------- Finding Main Orientation -------------%
[ HrLOrntPoints1 ] = mainOrient( HrLPoints1, img1gr, ThreshMainOrient, FactorMainOrient, AngleBinMainOrient, TypeOfMainOrient, SwitchWaitbars );
%------------------ Descripting -------------------%
[ DescriptHrLPoints1 ] = descriptFPoints( HrLOrntPoints1, img1gr, TypeOfDescriptor, NOfWindows, StepSampleFunction, AngleBinDescript, ThreshDescript, FactorDescript, SwitchWaitbars );
end
% save('test.mat');
if strcmp( TypeOfViewSimulation, 'second' ) || strcmp( TypeOfViewSimulation, 'both' )
cnt2 = 1;
DescriptHrLPoints2 = {};
HrLOrntPoints2 = {};
img2Orig = img2gr;
for t = TiltVectorRange
DeltaPhi = StepAngleFunction( t );
for phi = 0:DeltaPhi:(180-eps)
phiAngle = deg2rad( phi );
% defining tilt and longitude affin simulation matrix
T = zeros( 3 );
T(3,3)=1;
Tilt = eye(2);
Tilt(1) = t;
R = [ cos(phiAngle) -sin(phiAngle); sin(phiAngle) cos(phiAngle) ];
Aff = Tilt*R;
T( 1:2, 1:2 ) = Aff';
Tf = maketform('affine',T); % affine transformation for view-simulation
if strcmp(BlureTilt, 'yes')
sigma = BlureSigmaFunction( t );
if sigma > 0
g = fspecial( 'gaussian', [ 1, round( 6*sigma ) + 1 ], sigma );
img2gr = imfilter( img2Orig, g, 'same' );
else
img2gr = img2Orig;
end
else
img2gr = img2Orig;
end
BorderDistanceMatrix = zeros( m2, n2 );
BorderDistanceMatrix( (BorderDistance + 1):(m2 - BorderDistance), (BorderDistance + 1):(n2 - BorderDistance) ) = 1;
[ imgSimulated, xdata, ydata ] = imtransform( img2gr, Tf );
BorderDistanceMatrix = imtransform( BorderDistanceMatrix, Tf, 'xdata', xdata, 'ydata', ydata );
%- Finding FP and they char. scale (Harris-Laplace) -%
[ HrLPointsTmp2 ] = harrislpls( imgSimulated, TypeOfNBHOOD, NBHOOD, TypeOfCornerDetector, BorderDistanceMatrix, ThreshType, HarrisThresh, k, Dilate, radius, sigma_nmbr, disp, SwitchWaitbars );
%----------- Finding Main Orientation -------------%
[ HrLOrntPointsTmp2 ] = mainOrient( HrLPointsTmp2, imgSimulated, ThreshMainOrient, FactorMainOrient, AngleBinMainOrient, TypeOfMainOrient, SwitchWaitbars );
%------------------ Descripting -------------------%
[ DescriptHrLPointsTmp2 ] = descriptFPoints( HrLOrntPointsTmp2, imgSimulated, TypeOfDescriptor, NOfWindows, StepSampleFunction, AngleBinDescript, ThreshDescript, FactorDescript, SwitchWaitbars );
%----- Converting FP coordinates to original ------%
% back to coordinates, before shift for image coord. ( xdata(1) -> 1, ydata(1) -> 1 )
HrLOrntPointsTmp2( :, [ 2 5 ] ) = HrLOrntPointsTmp2( :, [ 2 5 ] ) - 1 + xdata(1);
HrLOrntPointsTmp2( :, [ 1 4 ] ) = HrLOrntPointsTmp2( :, [ 1 4 ] ) - 1 + ydata(1);
% back to original image coordinates
tmp = tforminv( Tf, HrLOrntPointsTmp2( :, 5 ), HrLOrntPointsTmp2( :, 4 ));
HrLOrntPointsTmp2( :, 2 ) = round(tmp(:,1)); HrLOrntPointsTmp2( :, 1 ) = round(tmp(:,2));
HrLOrntPointsTmp2( :, 1 ) = max( HrLOrntPointsTmp2( :, 1 ), 1 ); HrLOrntPointsTmp2( :, 1 ) = min( HrLOrntPointsTmp2( :, 1 ), m2 );
HrLOrntPointsTmp2( :, 2 ) = max( HrLOrntPointsTmp2( :, 2 ), 1 ); HrLOrntPointsTmp2( :, 2 ) = min( HrLOrntPointsTmp2( :, 2 ), n2 );
HrLOrntPointsTmp2( :, 5 ) = tmp(:,1); HrLOrntPointsTmp2( :, 4 ) = tmp(:,2);
% adding FP to all FP, that were founded before
DescriptHrLPoints2{cnt2} = DescriptHrLPointsTmp2;
HrLOrntPoints2{cnt2} = HrLOrntPointsTmp2;
cnt2 = cnt2 + 1;
end
end
else
[ HrLPoints2 ] = harrislpls( img2gr, TypeOfNBHOOD, NBHOOD, TypeOfCornerDetector, BorderDistance, ThreshType, HarrisThresh, k, Dilate, radius, sigma_nmbr, disp, SwitchWaitbars );
%----------- Finding Main Orientation -------------%
[ HrLOrntPoints2 ] = mainOrient( HrLPoints2, img2gr, ThreshMainOrient, FactorMainOrient, AngleBinMainOrient, TypeOfMainOrient, SwitchWaitbars );
%------------------ Descripting -------------------%
[ DescriptHrLPoints2 ] = descriptFPoints( HrLOrntPoints2, img2gr, TypeOfDescriptor, NOfWindows, StepSampleFunction, AngleBinDescript, ThreshDescript, FactorDescript, SwitchWaitbars );
end
% save('test.mat');
switch TypeOfViewSimulation
case 'first'
Match1 = []; Match2 = [];
for i = 1:(cnt1-1)
switch TypeOfMatchThresh
case 'first'
Thresh = ThreshF;
[ MatchedPairs ] = matchFPoints( DescriptHrLPoints1{i}, DescriptHrLPoints2, TypeOfSearch, HelpScalarOrVector, TypeOfMatchThresh, Thresh, SwitchWaitbars );
ind = find( MatchedPairs );
Match1Tmp = HrLOrntPoints1{i}( ind, [ 1 2 3 end ] );
ind = MatchedPairs( ind );
Match2Tmp = HrLOrntPoints2( ind, [ 1 2 3 end ] );
case 'first/second'
Thresh = ThreshFS;
[ MatchedPairs ] = matchFPoints( DescriptHrLPoints1{i}, DescriptHrLPoints2, TypeOfSearch, HelpScalarOrVector, TypeOfMatchThresh, Thresh, SwitchWaitbars );
ind = find( MatchedPairs );
Match1Tmp = HrLOrntPoints1{i}( ind, [ 1 2 3 end ] );
ind = MatchedPairs( ind );
Match2Tmp = HrLOrntPoints2( ind, [ 1 2 3 end ] );
case 'first/second&first'
Thresh = ThreshFS;
[ MatchedPairs ] = matchFPoints( DescriptHrLPoints1{i}, DescriptHrLPoints2, TypeOfSearch, HelpScalarOrVector, 'first/second', Thresh, SwitchWaitbars );
ind1 = find( MatchedPairs );
ind2 = MatchedPairs( ind1 );
% take only those pairs, that are at distance each from other less then ThreshF
ind = find( sqrt(sum( ((DescriptHrLPoints1{i}( ind1, : ) - DescriptHrLPoints2( ind2, : )).^2), 2 )) <= ThreshF );
ind1 = ind1( ind );
ind2 = ind2( ind );
Match1Tmp = HrLOrntPoints1{i}( ind1, [ 1 2 3 end ] );
Match2Tmp = HrLOrntPoints2( ind2, [ 1 2 3 end ] );
end
Match1 = [ Match1; Match1Tmp ]; Match2 = [ Match2; Match2Tmp ];
end
case 'second'
Match1 = []; Match2 = [];
for i = 1:(cnt2-1)
switch TypeOfMatchThresh
case 'first'
Thresh = ThreshF;
[ MatchedPairs ] = matchFPoints( DescriptHrLPoints1, DescriptHrLPoints2{i}, TypeOfSearch, HelpScalarOrVector, TypeOfMatchThresh, Thresh, SwitchWaitbars );
ind = find( MatchedPairs );
Match1Tmp = HrLOrntPoints1( ind, [ 1 2 3 end ] );
ind = MatchedPairs( ind );
Match2Tmp = HrLOrntPoints2{i}( ind, [ 1 2 3 end ] );
case 'first/second'
Thresh = ThreshFS;
[ MatchedPairs ] = matchFPoints( DescriptHrLPoints1, DescriptHrLPoints2{i}, TypeOfSearch, HelpScalarOrVector, TypeOfMatchThresh, Thresh, SwitchWaitbars );
ind = find( MatchedPairs );
Match1Tmp = HrLOrntPoints1( ind, [ 1 2 3 end ] );
ind = MatchedPairs( ind );
Match2Tmp = HrLOrntPoints2{i}( ind, [ 1 2 3 end ] );
case 'first/second&first'
Thresh = ThreshFS;
[ MatchedPairs ] = matchFPoints( DescriptHrLPoints1, DescriptHrLPoints2{i}, TypeOfSearch, HelpScalarOrVector, 'first/second', Thresh, SwitchWaitbars );
ind1 = find( MatchedPairs );
ind2 = MatchedPairs( ind1 );
% take only those pairs, that are at distance each from other less then ThreshF
ind = find( sqrt(sum( ((DescriptHrLPoints1( ind1, : ) - DescriptHrLPoints2{i}( ind2, : )).^2), 2 )) <= ThreshF );
ind1 = ind1( ind );
ind2 = ind2( ind );
Match1Tmp = HrLOrntPoints1( ind1, [ 1 2 3 end ] );
Match2Tmp = HrLOrntPoints2{i}( ind2, [ 1 2 3 end ] );
end
Match1 = [ Match1; Match1Tmp ]; Match2 = [ Match2; Match2Tmp ];
end
case 'both'
Match1 = []; Match2 = [];
for i = 1:(cnt1 - 1)
for j = 1:(cnt2 -1)
switch TypeOfMatchThresh
case 'first'
Thresh = ThreshF;
[ MatchedPairs ] = matchFPoints( DescriptHrLPoints1{i}, DescriptHrLPoints2{j}, TypeOfSearch, HelpScalarOrVector, TypeOfMatchThresh, Thresh, SwitchWaitbars );
ind = find( MatchedPairs );
Match1Tmp = HrLOrntPoints1{i}( ind, [ 1 2 3 end ] );
ind = MatchedPairs( ind );
Match2Tmp = HrLOrntPoints2{j}( ind, [ 1 2 3 end ] );
case 'first/second'
Thresh = ThreshFS;
[ MatchedPairs ] = matchFPoints( DescriptHrLPoints1{i}, DescriptHrLPoints2{j}, TypeOfSearch, HelpScalarOrVector, TypeOfMatchThresh, Thresh, SwitchWaitbars );
ind = find( MatchedPairs );
Match1Tmp = HrLOrntPoints1{i}( ind, [ 1 2 3 end ] );
ind = MatchedPairs( ind );
Match2Tmp = HrLOrntPoints2{j}( ind, [ 1 2 3 end ] );
case 'first/second&first'
Thresh = ThreshFS;
[ MatchedPairs ] = matchFPoints( DescriptHrLPoints1{i}, DescriptHrLPoints2{j}, TypeOfSearch, HelpScalarOrVector, 'first/second', Thresh, SwitchWaitbars );
ind1 = find( MatchedPairs );
ind2 = MatchedPairs( ind1 );
% take only those pairs, that are at distance each from other less then ThreshF
ind = find( sqrt(sum( ((DescriptHrLPoints1{i}( ind1, : ) - DescriptHrLPoints2{j}( ind2, : )).^2), 2 )) <= ThreshF );
ind1 = ind1( ind );
ind2 = ind2( ind );
Match1Tmp = HrLOrntPoints1{i}( ind1, [ 1 2 3 end ] );
Match2Tmp = HrLOrntPoints2{j}( ind2, [ 1 2 3 end ] );
end
Match1 = [ Match1; Match1Tmp ]; Match2 = [ Match2; Match2Tmp ];
% PlotMatches( img1, Match1Tmp, img2, Match2Tmp, 'sigma', TypeOfFP );
end
end
end
%--------------------- Ploting --------------------%
PlotMatches( img1, Match1, img2, Match2, 'sigma', TypeOfFP );
%
end

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 24 Apr. 2017
That appears to be a bug in the code.
Change the two references to disp into dispMatches

30 Kommentare

sir i changes disp into dispmatches. after changes this code when i run another error is showing like "Undefined function or variable 'harrislpls'.
Error in demoASIFT (line 105) [ HrLPointsTmp1 ] = harrislpls( imgSimulated, TypeOfNBHOOD, NBHOOD, TypeOfCornerDetector, BorderDistanceMatrix, ThreshType, HarrisThresh, k, Dilate, radius, sigma_nmbr, dispMatches, SwitchWaitbars );" sir wat do i do now
Make sure you download the complete https://www.mathworks.com/matlabcentral/fileexchange/29004-feature-points-in-image--keypoint-extraction . Then use pathtool to add the installation directory and all subdirectories to your MATLAB path.
sir from this website i have downloaded but i dont know about pathtool and sub directories installation. sir can you provide me the link wherr i have to download and install
sir i have added that all sub programs usng set path. but still im getting the same error
when i run this code again i m getting error like
"Error using sub2ind (line 43)
Out of range subscript.
Error in mainOrient (line 56)
LinearIndOfFPScale_i = sub2ind( [ Nrow, Nclmn ], row, clmn );
Error in demoASIFT (line 108)
[ HrLOrntPoints ] = mainOrient( HrLPointsTmp1, imgSimulated, ThreshMainOrient, FactorMainOrient,
AngleBinMainOrient, TypeOfMainOrient, SwitchWaitbars );
"
%%sub2ind
function ndx = sub2ind(siz,v1,v2,varargin)
%SUB2IND Linear index from multiple subscripts.
% SUB2IND is used to determine the equivalent single index
% corresponding to a given set of subscript values.
%
% IND = SUB2IND(SIZ,I,J) returns the linear index equivalent to the
% row and column subscripts in the arrays I and J for a matrix of
% size SIZ.
%
% IND = SUB2IND(SIZ,I1,I2,...,IN) returns the linear index
% equivalent to the N subscripts in the arrays I1,I2,...,IN for an
% array of size SIZ.
%
% I1,I2,...,IN must have the same size, and IND will have the same size
% as I1,I2,...,IN. For an array A, if IND = SUB2IND(SIZE(A),I1,...,IN)),
% then A(IND(k))=A(I1(k),...,IN(k)) for all k.
%
% Class support for inputs I,J:
% float: double, single
% integer: uint8, int8, uint16, int16, uint32, int32, uint64, int64
%
% See also IND2SUB.
% Copyright 1984-2015 The MathWorks, Inc.
siz = double(siz);
lensiz = length(siz);
if lensiz < 2
error(message('MATLAB:sub2ind:InvalidSize'));
end
numOfIndInput = nargin-1;
if lensiz < numOfIndInput
%Adjust for trailing singleton dimensions
siz = [siz, ones(1,numOfIndInput-lensiz)];
elseif lensiz > numOfIndInput
%Adjust for linear indexing on last element
siz = [siz(1:numOfIndInput-1), prod(siz(numOfIndInput:end))];
end
if any(min(v1(:)) < 1) || any(max(v1(:)) > siz(1))
%Verify subscripts are within range
error(message('MATLAB:sub2ind:IndexOutOfRange'));
end
ndx = double(v1);
s = size(v1);
if numOfIndInput >= 2
if ~isequal(s,size(v2))
%Verify sizes of subscripts
error(message('MATLAB:sub2ind:SubscriptVectorSize'));
end
if any(min(v2(:)) < 1) || any(max(v2(:)) > siz(2))
%Verify subscripts are within range
error(message('MATLAB:sub2ind:IndexOutOfRange'));
end
%Compute linear indices
ndx = ndx + (double(v2) - 1).*siz(1);
end
if numOfIndInput > 2
%Compute linear indices
k = cumprod(siz);
for i = 3:numOfIndInput
v = varargin{i-2};
%%Input checking
if ~isequal(s,size(v))
%Verify sizes of subscripts
error(message('MATLAB:sub2ind:SubscriptVectorSize'));
end
if (any(min(v(:)) < 1)) || (any(max(v(:)) > siz(i)))
%Verify subscripts are within range
error(message('MATLAB:sub2ind:IndexOutOfRange'));
end
ndx = ndx + (double(v)-1)*k(i-1);
end
%%mainorentation dunction
function [ HrLOrntPoints ] = mainOrient( HrLPoints, img, Thresh, Factor, AngleBin, TypeOfMainOrient, SwitchWaitbars )
% Function receives 'HrLPoints', and intensity image 'img', and returns
% matrix 'HrLOrntPoints' - with the same elements as HrLPoints, but with
% additional column, with values = main orientaion.
% Main orient. will be maximum value in h ( mx = max(h) ) ( weighted histogram of gradient angles ),
% with condition that there is no other peak grater then Thresh*max(h) - if TypeOfMainOrient = 'one'.
% If TypeOfMainOrient = 'some', then will be taken all orienations, that
% are biger then mx*Thresh ( for example, that are bigger then 80% of maximum-supported value ).
% Factor - scalar for smoothing gradients norm, see harrislpls.m
% AngleBin - interval's length for calc. angle weighted-histogram.
% TypeOfMainOrient - 'one'/'some'. Specifies how many characteristic
% orientations can be for FP.
img = double(img);
%----------- Defining edges for histogram -------------%
Edges4Hist = 0:AngleBin:360;
if Edges4Hist( end ) ~= 360
Edges4Hist( end + 1 ) = 360;
end
% defining number of bins
NOfBins = ceil( 360/AngleBin );
% finding range of scales
Scales = unique( HrLPoints( :, 3 ) );
NOfScales = length( Scales );
%------------------- Padding image --------------------%
% scalar 3, is good becuase I'm taking patch of size 3*scale to each direction from FP
Paddvalue = max( Scales ); Paddvalue = ceil( 3*Paddvalue );
img = padarray( img, [ Paddvalue Paddvalue ], 'symmetric' );
%------------------- Shifting coordinates --------------------%
HrLPoints( :, [ 1 2 4 5 ] ) = HrLPoints( :, [ 1 2 4 5 ] ) + Paddvalue;
[ Nrow, Nclmn ] = size(img);
% N = size(HrLPoints,1);
HrLOrntPoints = zeros(0,6);
if strcmp( SwitchWaitbars, 'on' )
h = waitbar(0,'Calculating main orientations:');
end
for i = 1:NOfScales
scale = Scales(i);
% defining linear indexes of elements in patch of size according to
% given sigma/Scales(i), near coord ( 0, 0 ).
win0ind = win2ind( Nrow, Nclmn, ceil( 3*scale ) );
% number of elements in each patch
sz = length( win0ind );
IndOfFP = find( HrLPoints( :, 3 ) == scale );
if ~isempty( IndOfFP )
row = round(HrLPoints( :, 4 )); clmn = round(HrLPoints( :, 5 ));
row = row( IndOfFP ); clmn = clmn( IndOfFP );
LinearIndOfFPScale_i = sub2ind( [ Nrow, Nclmn ], row, clmn );
NofFPScale_i = length( LinearIndOfFPScale_i );
% indexes shift for histc.m, in order that each patch/region of FP
% will be count separately
IndexShiftBins4Accum = NOfBins*(0:1:(NofFPScale_i-1));
IndexShiftBins4Accum = repmat( IndexShiftBins4Accum, sz, 1 );
IndexShiftBins4Accum = IndexShiftBins4Accum(:);
%------------------ Derivative mask -------------------%
x = -ceil(3*scale):ceil(3*scale);
[ X, Y ] = meshgrid(x,x);
dGdx = -X .* exp(-( X.*X + Y.*Y )/(2*scale*scale)) ./ ((scale^4)*(2*pi));
%-------------------- Derivatives ---------------------%
% 'normalized'
% Ix = scale*(imfilter(img, dGdx, 'same'));
% Iy = scale*(imfilter(img, dGdx', 'same'));
% not normalized - no point in normalization, won't influence the
% accumulation support of directions.
Ix = imfilter(img, dGdx, 'same');
Iy = imfilter(img, dGdx', 'same');
%----------------- Norm of gradients ------------------%
gradient_norm = sqrt(Ix.^2 + Iy.^2);
%------------- Avaraging norm gradients --------------%
g = fspecial('gaussian',max(1,fix(6*scale*Factor +1)), scale*Factor);
gradient_norm = imfilter(gradient_norm, g, 'same');
%----------------- Angles of gradients ----------------%
gradient_angles = rad2deg( atan2( Iy, Ix ) + pi );
%---------------- Combining all indexes ---------------%
% for FP IndOfFP(i), indexes of elements in patch near it are accomulated in
% column AllIndexes()
AllIndexes = repmat( win0ind(:), 1, NofFPScale_i ) + repmat( (LinearIndOfFPScale_i(:))', sz, 1 );
%------------------ Combining all data ----------------%
AllNorms = gradient_norm( AllIndexes );
AllAngles = gradient_angles( AllIndexes );
%-------------- Assigning angles 2 bins ---------------%
[ n, AngleBins ] = histc( AllAngles(:), Edges4Hist );
%---------------- Shifting angle bins -----------------%
AngleBinsShifted = AngleBins + IndexShiftBins4Accum;
%-------- Accumulating norms 2 according bins ---------%
AssignedNorms = accumarray( AngleBinsShifted, AllNorms(:), [ NOfBins*NofFPScale_i, 1 ] );
% reshaping it back, so each column corresponds to different FP
AssignedNorms = reshape( AssignedNorms, NOfBins, NofFPScale_i );
%------------------ Finding maximums ------------------%
[ mx IndOfBinOfMainOrient ] = max( AssignedNorms );
%--------------- Thresholding maximums ----------------%
MxMtr = repmat( mx*Thresh, NOfBins, 1 );
% taking maximum value ony if it the only one that bigger then Thrsh*( it's value )
switch TypeOfMainOrient
case 'some'
[ IndOfAngleBin IndexFP ] = find( MxMtr <= AssignedNorms );
case 'one'
IndexFP = find( sum(MxMtr <= AssignedNorms) == 1 );
IndOfAngleBin = IndOfBinOfMainOrient( IndexFP );
end
% indexes in HrLPoints of FP with MO
IndOfFP = IndOfFP( IndexFP );
%---------------- Assigning values /'max' -------------%
MainOrientations = AngleBin*IndOfAngleBin;
len = length(MainOrientations);
if len
HrLOrntPoints( (end + 1):(end + len), : ) = [ HrLPoints(IndOfFP, :), MainOrientations(:) ];
end
end
if strcmp( SwitchWaitbars, 'on' )
waitbar(i/NOfScales)
end
end
if strcmp( SwitchWaitbars, 'on' )
close(h);
end
HrLOrntPoints( :, [ 1 2 4 5 ] ) = HrLOrntPoints( :, [ 1 2 4 5 ] ) - Paddvalue;
end
sir do i run this code from command window or f5?
I will need your two images to test with.
sir i have attached 2 images here thank you sir
I have attached a repaired version of the contribution. It will at least run; I make no promises about it producing the right results.
ok sir i will run this and check. thank you sir
sir i have run that code but i m getting error on "disp" Error using disp Too many output arguments.
Error in demoASIFT (line 178) [ HrLPoints ] = harrislpls( imgSimulated, TypeOfNBHOOD, NBHOOD, TypeOfCornerDetector, BorderDistanceMatrix, ThreshType, HarrisThresh, k, Dilate, radius, sigma_nmbr, disp, SwitchWaitbars );
>>
No, you are not using the contents of the .zip that I posted. I downloaded it to check in case I posted the wrong thing, but I confirm that the version I posted has that repaired.
Download the FPS_in_image 2.zip that I posted, and unzip it into a new directory. Use pathtool to add that directory and all its subdirectories to the path, and make sure you remove from the path the directory and subdirectories that you had installed into before.
sir i have tried this FPS_in_image 2.zip coding sir. but still i m getting error."Error in demoASIFT (line 302) [ MatchedPairs ] = matchFPoints( DescriptHrLPoints1{i}, DescriptHrLPoints2{j}, TypeOfSearch, HelpScalarOrVector, 'first/second', Thresh, SwitchWaitbars );
Error using pdist2 (line 74) pdist2 - unknown metric: squaredeuclidean
Error in matchFPoints (line 125) Dist = pdist2( DescriptHrLPoints2, DescriptHrLPoints1, 'squaredeuclidean' ); wat correctiob shall i do sir?
Which MATLAB version are you using?
squaredeuclidean is documented for R2016a.
I will test later today.
ok sir. thank you so much sir. let me know whenever you find it.
It works in R2016a.
Note: the documentation mentions about using pdist2 out of a third party toolbox. The version I posted uses pdist2 out of the Statistics toolbox. Use
which -all pdist2
to see if you have multiple pdist2, and use pathtool to make sure that the Statistics Toolbox one is earlier on your search path.
thanks sir it dosnt show any error but again error in filter function.Error using imfilter>parse_inputs (line 196) Not enough input arguments. error in imfilter (line 115) [a, h, boundary, sameSize, convMode] = parse_inputs(varargin{:}); what do i add for input arguments?
Please show the complete traceback message, showing where imfilter was called from.
sir now it doesn't show error but when i tried yesterday it throws an error thank you very much sir
sir can you share your output what you got after running asift? still im getting error on it sir
If
which pdist2
shows something under FPS_In_Image such as
FPS_in_image/FPS in image/Help Functions/SearchingMatches/pdist2.m
then you have FPS_in_image too early on your MATLAB path and should use pathtool to move all of the FPS_in_image directories to the bottom.
If you happen to be cd'd to that directory then you could still have problems. For that situation, you can change one line of the pdist2.m file that you find there. The replacement is attached.
sir i m getting an error like this now. demoASIFT Error using imtransform>check_A (line 478) A must be a nonsparse numeric array.
Error in imtransform>parse_inputs (line 372) args.A = check_A(varargin{1});
Error in imtransform (line 265) args = parse_inputs(varargin{:});
Error in demoASIFT (line 102) [ imgSimulated, xdata, ydata ] = imtransform( img1gr, Tf );
Please indicate which MATLAB version you are using.
Please attach the following:
  • Your two images
  • The complete FPS_In_Image directory that you are using, including all changes
  • disp(path) and attach a copy of the output
version 2016a C:\Users\murali\Desktop\FPS_in_image\FPS_in_image\FPS in image\Help Functions\Demos, scripts
sir i have attached my logos here. i m not geting any output sir
Unfortunately the FPS_in_images directory did not get attached.
The code works for me; the output is:
sir what do i do now sir? cant i get the same output?
I do not know. You did not attach your FPS_in_images so that I could verify that we are using the same code.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

xingkun li
xingkun li am 12 Apr. 2018
you can copy these functions to the floder,such as : harrislpls..

Community Treasure Hunt

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

Start Hunting!

Translated by