内容へ移動
講義(山本裕樹)
ユーザ用ツール
ログイン
サイト用ツール
検索
ツール
文書の表示
バックリンク
最近の変更
メディアマネージャー
サイトマップ
ログイン
>
最近の変更
メディアマネージャー
サイトマップ
トレース:
numericalipb:ans5
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== 【数値情報処理b】第5回の答え ====== ===== 課題 ===== label.R を書き換えて以下の画像から「公」の文字のみを抜き出すプログラムを作成しなさい。 https://www.kitp.org/numericalipb/nameplate1.jpg ただし、画像は人によって違う。 ---- ==== 解答例 ==== <file rsplus report5.R[enable_line_numbers="true",highlight_lines_extra="6,23"]> # レポート library(imager) # グレースケール画像 im <- grayscale(load.image("https://www.kitp.org/numericalipb/nameplate1.jpg")) # 2値化 im.bin <- threshold(im, "auto") # ラベリング x <- label(im.bin) # ラベル付けされた図形の面積(画素数) areas <- table(x) # 面積が100以上の図形のラベルと面積を出力 print(areas[areas >= 100]) # ラベルを指定して図形を抜き出す im.ex <- im im.ex[x != 6 & x != 7 & x != 14] <- 1 layout(t(1 : 2)) plot(im, main = "元画像") plot(im.ex, main = "抜き出した図形") layout(1) </file> 人によって 6 行目と 23 行目が異なる。
numericalipb/ans5.txt
· 最終更新: 2025/07/16 14:22 by
yuki
ページ用ツール
文書の表示
バックリンク
文書の先頭へ