Error: Expected input to be a vector
17 ビュー (過去 30 日間)
古いコメントを表示
Hi folks,
I am calling a self-made function as follows:
ir = rotateAround(ig, Cy, Cx, Angle_DEG);
But the last variable, Angle_DEG, has no value so I get an error when calling this function. Angle_DEG is returned bu a different function as:
[Angle_DEG, LinePoint1, LinePoint2] = RotatedAngle(RawImages, files, xmin, ymin, CropH, CropW, a, i);
where rotatedAngle is returning all outputs without an actual numeric value...Any ideas why this might be please? The function is defined as follows:
function [ Angle_DEG, LinePoint1, LinePoint2] = RotatedAngle( RawImages, files, xmin, ymin, CropH, CropW, a, i )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
% Finding the angle for auto rotation of the image
% Then recropping to remove the black edges due to rotation
%% Finding the Image rotation based on the initial image %%
file_name = files(i).name;
im = imread([RawImages '\' file_name]);
ig = rgb2gray(im(:,:,1:3));
I = imcrop(ig,[xmin(i) ymin(i) CropW(a) CropH(a)]);
%%% Using edge detection %%%
Bw = imbinarize(I, 24/255);
IE = edge(Bw,'canny');
%imshow(IE);
%IE = edge(I,'canny',0.25); %IE = edge(I,'canny',0.23)
%% Getting data points for the tile %%
% (X1,Y1) Point on the left
X1 = round((size(IE,2))*1/10);
X1line = IE(:,X1);
Y1s = find(X1line==1,500);
Y1s(Y1s == 0) = inf;
LinePoint1 = max(Y1s,[],1);
% (X2,Y2) Point on the right
X2 = round((size(IE,2))*9/10);
X2line = IE(:,X2);
Y2s = find(X2line==1,500);
Y2s(Y2s == 0) = inf;
LinePoint2 = max(Y2s,[],1);
%Y2Table(i) = Y2;
%Angle between the line and the horizontal
Coordinates = [X1,LinePoint1;X2,LinePoint2];
Dist = pdist(Coordinates,'euclidean'); % not necessary
Angle_DEG = atan2(LinePoint2-LinePoint1,X2-X1)*180/pi;
end
0 件のコメント
採用された回答
Max Heiken
2021 年 6 月 10 日
It seems to me Cy and Cx must be column vectors, that is how I could reproduce the error. The function can only handle scalars for Cy and Cx. If you need to rotate your image around many points, I suggest you do it in a loop instead.
6 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!