フィルターのクリア

my output value is double not logical

2 ビュー (過去 30 日間)
tsai kai shung
tsai kai shung 2017 年 10 月 27 日
コメント済み: Stephen23 2017 年 10 月 27 日
clear all;
clc;
img = imread('green2.jpg');
img_gray = rgb2gray(img);
level = graythresh(img);
img_bw = im2bw(img_gray,level);
imshow(img_bw);
[L2,num2]=bwlabel(img_bw,8); %連通區域標記
B2=false(size(L2));
for i=1:num2
[r,c] = find(L2==i);
left = min(c);
right = max(c);
up = min(r);
down = max(r);
d = (down-up) / (right-left);
if d > 0.8 & d < 1
% [x,y]=find(L2==i); % Done above already
B2 = B2 + bwselect(img_bw, c, r, 8); %%%把滿足長寬比在0.8到2的區域留下
end
end
figure,imshow(B2);
why my B2 set logical but output is double value?
  1 件のコメント
Stephen23
Stephen23 2017 年 10 月 27 日
>> class(true+true)
ans = double

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

採用された回答

KSSV
KSSV 2017 年 10 月 27 日
編集済み: KSSV 2017 年 10 月 27 日
A = logical(round(rand(2))) ; % a logical class
B = rand(2) ; % a double class
C = A+B ; % operation between logical and double gives double
So in your case B2 is logical and the output from bwselect(img_bw, c, r, 8) is double....so the result is double.
Have a look on logical and double if you want any conversions.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!