Borrar filtros
Borrar filtros

my output value is double not logical

2 visualizaciones (últimos 30 días)
tsai kai shung
tsai kai shung el 27 de Oct. de 2017
Comentada: Stephen23 el 27 de Oct. de 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?

Respuesta aceptada

KSSV
KSSV el 27 de Oct. de 2017
Editada: KSSV el 27 de Oct. de 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.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!