How to update area on iteration process?
이전 댓글 표시
Hi, everyone.. can someone help me? I'm still newbie and I'm doing task about segmentation using triclass thresholding but I got confused on the iteration process because TBD area must updated on each iteration. Here the algorithm : 1) Input image 2) find threshold using otsu method 3) divide into 2 area based on threshold (e.g : R1<= T, and R2>T) 4) calculate the mean of R1 and R2 (e.g : miu1 and miu2) 5) divide into 3 class : Background is less than miu1 TBD is between miu1 and miu2 Foreground is more than miu2 6) display TBD 7) do step 2-6 until new threshold same as the previous threshold *Note : the last TBD divide into 2 class (background<=T, foreground>T) can someone help me how to coding the iteration process? thank you
답변 (1개)
file = 'rice.png';
I = imread(file);
TBD = im2uint8(id(:));
T = graythresh(I2);
Th = uint8(255*T1);
T2 = T;
while max(abs(T(:) - T2(:)) > Limit
T = T2;
r1 = I2(TBD<Th);
r2 = I2(TBD>=Th);
miu1 = uint8(mean2(r1));
miu2 = uint8(mean2(r2));
TBD = TBD(TBD>=miu1 & I2<miu2);
B1 = TBD(TBD<miu1);
F1 = TBD(TBD>=miu2);
T2 = graythresh(TBD);
Th = uint8(255*T2);
end
Perhaps something like this with a suitable Limit to consider rounding effects?
This is untested code and I've edited it just by replacing the patterns in the names of the variables without understanding, what the code does.
카테고리
도움말 센터 및 File Exchange에서 Polygonal Shapes에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!