特定の範囲における二値化について(初心者です)

25 views (last 30 days)
coco
coco on 17 Jan 2021
Commented: coco on 24 Jan 2021
二値化において、imbinarizeを用いているのですが、 イメージAの左半分の閾値を右半分の閾値よりも高く設定して二値化したいです。
そこで以下のような方法で行ってみたところエラーが出てしまいました。 改善点を教えて頂きたいです。 よろしくお願い致します。
binariA=imbinarize(A(:,1:end/2),ave*2)+ imbinarize(A(:,end/2:end),ave);
左半分の閾値を右半分の閾値の2倍にしてみました。
  2 Comments
Shunichi Kusano
Shunichi Kusano on 18 Jan 2021
どのようなエラーが出たのかも記載いただけると回答者の参考になるかと思います。
coco
coco on 24 Jan 2021
アドバイスありがとうございます! 次回エラーが出た時は記載するようにしたいと思います!

Sign in to comment.

Accepted Answer

Akira Agata
Akira Agata on 22 Jan 2021
以下のような処理になるかと思いますが、いかがでしょう?
% グレースケール画像を準備
I = imread('cameraman.tif');
% 幅の半分、閾値1、閾値2を準備
wHalf = round(size(I,2)/2);
th1 = uint8(50);
th2 = uint8(150);
% 左半分と右半分を異なる閾値で2値化
BW = [I(:,1:wHalf)>th1, I(:,wHalf+1:end)>th2];
% 確認
figure
imshowpair(I,BW,'montage')
  1 Comment
coco
coco on 24 Jan 2021
ありがとございます! 参考にさせて頂きます!!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!