画像処理後,面積などを抽出して保存する
Mostra commenti meno recenti
指定画像を読み込んだあと,
背景処理・2値化 ⇒ 面積等を抽出 ⇒ 値を保存(テキストなど)したいのですが,以下2つのエラーがでます。
どのように修正したらよいでしょうか。
・★エラー(double から structに変換できません。)がでて実行できません.
・★fprintf のところで、'AREA','MajorAxisLength','Centroid'の値を出力できませんでした.
宜しくお願いいたします
%画像,背景画像(8bit)を読み込み
img=imread('IMG001.tif');
imgb=imread('IMGB001.tif'); %背景だけの画像
%背景をカットして二値化
bw=img-imgb; %背景より明るいところを取り出します
bw=double(bw);
BW=imbinarize(bw,50); %50で二値化
%面積などを抽出
AREA=regionprops(BW,'Area');
MajorAxisLength=regionprops(BW,'MajorAxisLength');
Centroid=regionprops(BW,'Centroid');
%保存形式作成
A=[a; AREA; MajorAxisLength; Centroid]; % a = 1などの変数です
%★エラー struct%double から struct に変換できません。
%書き込み
fid = fopen('test.txt','w');
fprintf(fid,'%8s %18s %12s %8s \r\n','a','AREA','MajorAxisLength','Centroid');
fprintf(fid,'%8.1f %18.2f %18.2f %18.2f\n',A);
fclose(fid);
%★fprintf で'AREA','MajorAxisLength','Centroid'の値が出力きません
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su イメージ算術 in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!