필터 지우기
필터 지우기

how to find regionprops max(area) ind?

조회 수: 6 (최근 30일)
tsai kai shung
tsai kai shung 2017년 10월 30일
답변: tsai kai shung 2017년 10월 30일
if true
clear all;
clc;
img = imread('40.jpg');
tic
I = rgb2hsv(img);
channel1Min = 0.956; channel1Max = 0.006;
channel2Min = 0.594; channel2Max = 0.886;
channel3Min = 0.529; channel3Max = 0.780;
sliderBW = (I(:,:,1) >= channel1Min ) | (I(:,:,1) <= channel1Max) &(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & (I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max); BW = sliderBW; bw3 = areaimg(BW); bw3 = ratioimg(bw3); imshow(bw3); S = regionprops(bw3,'BoundingBox','Area'); BW_2 = imcrop(img,[S.BoundingBox(1,:)]); end
i have a problem that is If the noise in my image is not filtered clean then the regionprops show Two or more struct then It will show an error so how to use one ind to replace imcrop(img,[S.BoundingBox(1,:)]);
  댓글 수: 1
tsai kai shung
tsai kai shung 2017년 10월 30일
if true
clear all;
clc;
img = imread('40.jpg');
tic
I = rgb2hsv(img);
channel1Min = 0.956; channel1Max = 0.006;
channel2Min = 0.594; channel2Max = 0.886;
channel3Min = 0.529; channel3Max = 0.780;
sliderBW = (I(:,:,1) >= channel1Min ) | (I(:,:,1) <= channel1Max) &(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & (I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
BW = sliderBW;
bw3 = areaimg(BW);
bw3 = ratioimg(bw3); imshow(bw3);
S = regionprops(bw3,'BoundingBox','Area');
BW_2 = imcrop(img,[S.BoundingBox(1,:)]);
end

댓글을 달려면 로그인하십시오.

답변 (1개)

tsai kai shung
tsai kai shung 2017년 10월 30일
this is my crop image

Community Treasure Hunt

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

Start Hunting!