Azzera filtri
Azzera filtri

my output value is double not logical

2 visualizzazioni (ultimi 30 giorni)
tsai kai shung
tsai kai shung il 27 Ott 2017
Commentato: Stephen23 il 27 Ott 2017
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?

Risposta accettata

KSSV
KSSV il 27 Ott 2017
Modificato: KSSV il 27 Ott 2017
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.

Più risposte (0)

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!