粒子一つ一つを解析したいです
17 views (last 30 days)
Show older comments
Naoki Hashiguchi
on 24 Nov 2022
Commented: Naoki Hashiguchi
on 27 Nov 2022
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1205103/image.bmp)
clear all,close all,clc;
%%指定領域の画像の読み込み
j = imread('10000fps_Al_0.2mm_70GLY_bottom_doublelight_S0001_S0001.bmp');
[I,rect] = imcrop(j);
figure,imshow(I)
%%2値化
BW = I < 50
%プロパティ解析
state = regionprops(BW,'Area','Centroid');
%%ラベル画像の作製
L = bwlabel(BW);
RGB = label2rgb(L);
figure,imshow(L);
使い方によるエラー bwlabel
1 番目の入力引数 BWは2 次元にする必要があります。
上記のプログラムを使用して灰色の粒子を2値化しBWを2次元にしたいのですがエラーがでますどのようにしたらいいでしょうか?
0 Comments
Accepted Answer
Atsushi Ueno
on 27 Nov 2022
添付の画像のサイズは 256*512*3 です。見た目は白黒ですがこれはカラー画像データです。
clear,close all; clc;
%%指定領域の画像の読み込み
%j = imread('10000fps_Al_0.2mm_70GLY_bottom_doublelight_S0001_S0001.bmp');
j = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1205103/image.bmp');
gry = imcrop(im2gray(j), [150,1,300,512]); % RGB⇒グレースケール化、指定領域を仮固定
%figure,imshow(gry)
%%コントラスト調整
adj = imadjust(gry, stretchlim(gry), []); % 追加:コントラスト調整
%figure,imshow(adj)
%%2値化
BW = imbinarize(adj); %BW = j < 50 % imbinarize関数に変更
%figure,imshow(BW)
%%プロパティ解析
state = regionprops(BW,'Area','Centroid');
%%ラベル画像の作製
L = bwlabel(BW);
RGB = label2rgb(L);
%figure,imshow(L);
他にもちょいちょい変更を入れて下記の様な結果になりました。
(左上:元画像、右上:領域指定、左下:コントラスト調整、右下:2値化)
montage({j,gry,adj,BW});
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox 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!