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
340
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
Transcript
14 slides
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/
More Decks by Newbees Inc
See All by Newbees Inc
Matching theory-based recommender systems in online dating
newbees
0
160
Siamese neural networks in recommendation
newbees
0
150
Newbees採用資料(2026.11更新)
newbees
2
60k
Other Decks in Programming
See All in Programming
エラーチャンネルのボールを拾い続けて鍛えるエンジニアの地力 / phpcon-niigata2026
meihei3
1
230
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
360
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
150
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
240
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
210
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.4k
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
210
Snowflake Openflow Connector利用の勘所 / 20261024developersio2026tokyo-snowflake-openflow
kasacchiful
PRO
0
350
Distance field of Julia set
kinakomoti321
0
330
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
130
AI-Powered Domain-Driven Design
ziobrando
0
460
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
210
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
530
Skip the Path - Find Your Career Trail
mkilby
1
290
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.7k
Typedesign – Prime Four
hannesfritz
42
3.2k
HDC tutorial
michielstock
2
1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
How to Ace a Technical Interview
jacobian
280
24k
Accessibility Awareness
sabderemane
1
300
Rails Girls Zürich Keynote
gr2m
96
14k
Faster Mobile Websites
deanohume
310
32k
Art, The Web, and Tiny UX
lynnandtonic
304
22k