Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Goで並⾏処理を⽤いた 画像処理を実装した話|株式会社Newbees
Search
Newbees Inc
June 05, 2023
Programming
320
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Goで並⾏処理を⽤いた 画像処理を実装した話|株式会社Newbees
2023年6月1日に開催された「Go Conference2023」
登壇した際の資料となります。
Newbees Inc
June 05, 2023
More Decks by Newbees Inc
See All by Newbees Inc
Matching theory-based recommender systems in online dating
newbees
0
150
Siamese neural networks in recommendation
newbees
0
140
Newbees採用資料(2026.04更新)
newbees
2
59k
Other Decks in Programming
See All in Programming
setup-vp GitLab対応の裏側
naokihaba
0
130
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
310
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
360
The Rails Doctrine Decade
koic
2
390
Heart of Swift Concurrency
koher
0
990
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
530
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
430
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
280
カツオ、ご期待ください
suneo3476
0
100
Security issues being discussed on Web Platforms
petamoriken
0
1.2k
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
200
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1.1k
Featured
See All Featured
Test your architecture with Archunit
thirion
2
2.4k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
240
Are puppies a ranking factor?
jonoalderson
2
3.9k
ラッコキーワード サービス紹介資料
rakko
1
5M
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Balancing Empowerment & Direction
lara
6
1.3k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
250
Between Models and Reality
mayunak
4
470
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
550
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
370
We Are The Robots
honzajavorek
0
380
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Transcript
Goで並⾏処理を⽤いた 画像処理を実装した話 Yuya Hiramatsu Go Conference 2023 (2023-06-02)
⾃⼰紹介 株式会社Newbees 所 属 バックエンド, iOS, 研究開発(画像解析, 機械学習) 担 当
Yuya Hiramatsu 名 前 Goでは主に画像解析の実装経験がある
背景 要件:ユーザーから受信した⾝分証画像の番号をモザイク加⼯する OCRにより画像内から検出された⽂字の位置情報を元に 任意の4点を結ぶ四⾓形内をモザイク加⼯する処理を実装 保険証の番号をモザイク加⼯した例
背景 ⽬的の画像処理ライブラリがなかったため独⾃で実装する必要があった 並⾏処理を⽤いて処理時間の⾼速化を図る 保険証の番号をモザイク加⼯した例
アルゴリズム 1. ⽂字を囲う四⾓形内を複数のブロックに区切る 2. 各ブロック内の平均ピクセル値を求める 3. 各ブロック内の全てのピクセルを2.で求めた平均ピクセル値に更新する
アルゴリズム 1. ⽂字を囲う四⾓形内を複数のブロックに区切る 2. 各ブロック内の平均ピクセル値を求める 3. 各ブロック内の全てのピクセルを2.で求めた平均ピクセル値に更新する
アルゴリズム 各ブロックの処理を複数のgoroutineで⾏い並⾏処理化する goroutine A goroutine B goroutine C goroutine D
4つのgoroutineで処理する例
// goroutine起動 // 起動するgoroutine数 // i番⽬のgoroutineが処理するブロックの範囲 // 全てのgoroutineの処理が終わるまで待機 // (x,
y)番地のブロックのマスキング処理 並⾏処理部分のソースコード
実験環境 l MacBook Pro M1(2021) • メモリ16GB, 8スレッド l 画像:スマホで撮影した⾝分証
• サイズ:3024×4032 [pixel] • マスキング対象箇所:5箇所 l ベンチマーク testingパッケージのBenchmark関数 対象画像の例 (⾚枠がマスキング対象)
ベンチマーク 並⾏処理化前 並⾏処理化後 平均処理時間 割り当てられた メモリ量 割り当て回数 実⾏回数 およそ3倍速くなった
余談:並⾏処理化に伴ったアルゴリズムの変更 従来⼿法:並⾏処理化が難しく計算コストが⾼い 四⾓形内のピクセルを抽出する際に端から連続的に操作する必要があり 複数スレッドでの処理分割が困難だった 2度⽬に境界線に当たったら 内部判定終了 端から順番にピクセルを⾒ていき 初めて境界線に当たったら内部判定開始
余談:並⾏処理化に伴ったアルゴリズムの変更 各ピクセルごとに独⽴して処理できるアルゴリズムに改修 サイズが⼤きい画像において処理時間が平均3秒改善された
考察とまとめ l 画像処理の並⾏処理化により処理速度が向上 • 画像処理は並⾏処理可能な計算が多いため並⾏処理に向いている • goroutineを⽤いる実装の⼿軽さを実感 l アルゴリズムの変更により処理速度が⼤幅に向上 •
処理を⾼速化したい場合はまず初めにアルゴリズムを⾒直すことが 重要
Engineer、Designer、Director、QA、HRGA Newbeesでは全ての部署で⼀緒に働くメンバーを募集中です! We Are Hiring! Newbees 採⽤情報 https://newbees.jp/career/