Error using ' Transpose on ND array is not defined. Use PERMUTE instead.

1 回表示 (過去 30 日間)
vani shree
vani shree 2017 年 4 月 21 日
コメント済み: vani shree 2017 年 4 月 23 日
sir when i run match.m in command window it is showing like this error. please help me sir. how to resolve this. errors are, Error using ' Transpose on ND array is not defined. Use PERMUTE instead.
Error in sift (line 38) fwrite(f, image', 'uint8');
Error in match (line 14) [im1, des1, loc1] = sift(image1);
>>
if true
% % [image, descriptors, locs] = sift(imageFile)
%
% This function reads an image and returns its SIFT keypoints.
% Input parameters:
% imageFile: the file name for the image.
%
% Returned:
% image: the image array in double format
% descriptors: a K-by-128 matrix, where each row gives an invariant
% descriptor for one of the K keypoints. The descriptor is a vector
% of 128 values normalized to unit length.
% locs: K-by-4 matrix, in which each row has the 4 values for a
% keypoint location (row, column, scale, orientation). The
% orientation is in the range [-PI, PI] radians.
%
% Credits: Thanks for initial version of this program to D. Alvaro and
% J.J. Guerrero, Universidad de Zaragoza (modified by D. Lowe)
function [image, descriptors, locs] = sift(imageFile)
% Load image image = imread(imageFile);
% If you have the Image Processing Toolbox, you can uncomment the following % lines to allow input of color images, which will be converted to grayscale. % if isrgb(image) % image = rgb2gray(image); % end
[rows, cols] = size(image);
% Convert into PGM imagefile, readable by "keypoints" executable f = fopen('tmp.pgm', 'w'); if f == -1 error('Could not create file tmp.pgm.'); end fprintf(f, 'P5\n%d\n%d\n255\n', cols, rows); fwrite(f, image', 'uint8'); fclose(f);
% Call keypoints executable if isunix command = '!./sift '; else command = '!siftWin32 '; end command = [command ' <tmp.pgm >tmp.key']; eval(command);
% Open tmp.key and check its header g = fopen('tmp.key', 'r'); if g == -1 error('Could not open file tmp.key.'); end [header, count] = fscanf(g, '%d %d', [1 2]); if count ~= 2 error('Invalid keypoint file beginning.'); end num = header(1); len = header(2); if len ~= 128 error('Keypoint descriptor length invalid (should be 128).'); end
% Creates the two output matrices (use known size for efficiency) locs = double(zeros(num, 4)); descriptors = double(zeros(num, 128));
% Parse tmp.key for i = 1:num [vector, count] = fscanf(g, '%f %f %f %f', [1 4]); %row col scale ori if count ~= 4 error('Invalid keypoint file format'); end locs(i, :) = vector(1, :);
[descrip, count] = fscanf(g, '%d', [1 len]);
if (count ~= 128)
error('Invalid keypoint file value.');
end
% Normalize each input vector to unit length
descrip = descrip / sqrt(sum(descrip.^2));
descriptors(i, :) = descrip(1, :);
end
fclose(g);
end
sir please help me sir. i have attached my coding here

採用された回答

James Tursa
James Tursa 2017 年 4 月 21 日
編集済み: James Tursa 2017 年 4 月 21 日
Try changing this line
fwrite(f, image', 'uint8');
to this (transposes the first two dimensions)
fwrite(f, permute(image,[2 1 3]), 'uint8');
and see if that does what you want.
  2 件のコメント
vani shree
vani shree 2017 年 4 月 22 日
thank you sir its working perfectly.. you opened my eyes!! thank you very much
vani shree
vani shree 2017 年 4 月 23 日
good morning sir. sir can you help me to run ASIFT algorithm? i have coding which i have downloaded from matlab website. but i dont know to run this? please help me sir. i have attached ASFIT coding folder. help me sir.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFeature Detection and Extraction についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by