Azzera filtri
Azzera filtri

フォルダ内の画像を読​み込み,そのlab値​をcsvファイルに出​力する.

14 visualizzazioni (ultimi 30 giorni)
周也 寺内
周也 寺内 il 1 Apr 2022
Commentato: 周也 寺内 il 4 Mag 2022
フォルダ内にある画像(fabric.png)の画像を読み込む.
画像のlab値を配列(3×n)に入れる.
lab値の配列をcsvファイルに出力する.

Risposta accettata

Atsushi Ueno
Atsushi Ueno il 2 Apr 2022
>画像のlab値を配列(3×n)に入れる.
下図の様に解釈しました。例えば画素数が10*10=100なら配列(3×100)になります
(値は適当です。A列のラベル名は説明用で実際には入りません)
pic = uigetfile; % 画像ファイルの選択 (fabric.pngを選択してください)
rgb = imread(pic); % 画像ファイルの読込
lab = rgb2lab(rgb); % 画像のlab値(縦x横x3)を取得
lab = permute(lab,[3 1 2]); % (縦x横x3)⇒(3x縦x横)にする
lab = reshape(lab,[3 numel(rgb)/3]); % (3x縦x横)⇒(3×n)にする(n=縦x横)
[filepath,name,ext] = fileparts(pic); % 画像ファイル名を取得
writematrix(lab, [name '.csv']); % lab値の配列をcsvファイルに出力する
  1 Commento
周也 寺内
周也 寺内 il 4 Mag 2022
本件ありがとうございます.
無事動作いたしました.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su インポート、エクスポートおよび変換 in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!