How to detect the object in my picture that be horizontal vertical or spot ?

4 ビュー (過去 30 日間)
Ajaree Rattanaharn
Ajaree Rattanaharn 2019 年 2 月 8 日
回答済み: KSSV 2019 年 2 月 8 日
I have many pictures. as the picture below
  1. Vertical
  2. Horizontal
  3. spot
spot.jpg
horizontal.jpg
vertical.jpg
What should I write the codes to detect specific my picture that is vertical horizontal or spot?
Please help me if you can^^
love you
Thank you for your attention ^^

採用された回答

KSSV
KSSV 2019 年 2 月 8 日
I = imread('spot.jpeg') ;
I = rgb2gray(I) ;
[y,x] = find(I==0) ;
%% Remove outliers
idx = abs(x-mean(x))>3*nanstd(x) ;
idy = abs(y-mean(y))>3*nanstd(y) ;
id = idx|idy ;
x(id) = [] ; y(id) = [] ;
%% Get length and breadth
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
L = y1-y0 ;
B = x1-x0 ;
figure
imshow(I)
hold on
plot(x,y,'.r')
If L > B, than vertical
If L < B, than horizontal

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Analytics Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by