my output value is double not logical
조회 수: 2 (최근 30일)
이전 댓글 표시
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?
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!