接する円を作製して幅を測定したいです。
Show older comments
下記コードを用い、添付の液体画像(Image1.bmp)を読み込んで、二値化してスケルトン処理で中心線をだします。
その後、その中心線状に中心を持ち、元画像の液体の両方に接するような円を作製し、その直径から幅をはかるプログラムが作製したいです。
以下、スケルトン処理までのコードです。
宜しくお願いいたします。
%画像の読み込み
file1 = 'Image1.bmp';
I1 = imread(file1);
%二値化
BW1 = imbinarize(I1,0.528);
%左側除去
BW1(1:256,1:159) = 1;
%右側除去
BW1(1:256,259:512) = 1;
%白黒反転
BW1 = imcomplement(BW1);
%画像調整
BW1 = bwareafilt(BW1,1);
BW1 = imfill(BW1,"holes");
%モルフォロジー処理
BW2 = bwskel(BW1,'MinBranchLength',50);
BW2 = bwareaopen(BW2,4);
BW2(223:256,1:512) = 0;
%元画像に液体中心線を重ねる
BW2 = imcomplement(BW2);
file2 = "Image2.bmp";
imwrite(BW2,file2);
I2 = imread(file2);
masked_image = I1 .* uint8(I2);
file3 = "Image3.bmp";
imwrite(masked_image,file3);

Accepted Answer
More Answers (0)
Categories
Find more on コントラストの調整 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



