Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Goで並⾏処理を⽤いた 画像処理を実装した話|株式会社Newbees
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Newbees Inc
June 05, 2023
Programming
0
290
Goで並⾏処理を⽤いた 画像処理を実装した話|株式会社Newbees
2023年6月1日に開催された「Go Conference2023」
登壇した際の資料となります。
Newbees Inc
June 05, 2023
Tweet
Share
More Decks by Newbees Inc
See All by Newbees Inc
Matching theory-based recommender systems in online dating
newbees
0
130
Siamese neural networks in recommendation
newbees
0
120
Newbees採用資料(2026.02更新)
newbees
2
50k
Other Decks in Programming
See All in Programming
Tamach-sre-3_ANDPAD-shimaison93
mane12yurks38
0
140
脱 雰囲気実装!AgentCoreを良い感じにWEBアプリケーションに組み込むために
takuyay0ne
3
410
Understanding Apache Lucene - More than just full-text search
spinscale
0
140
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
370
20260320登壇資料
pharct
0
130
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.4k
ローカルで稼働するAI エージェントを超えて / beyond-local-ai-agents
gawa
0
170
Coding at the Speed of Thought: The New Era of Symfony Docker
dunglas
0
2.6k
PHPで TLSのプロトコルを実装してみる
higaki_program
0
530
どんと来い、データベース信頼性エンジニアリング / Introduction to DBRE
nnaka2992
1
340
Smarter Angular mit Transformers.js & Prompt API
christianliebel
PRO
1
100
How to stabilize UI tests using XCTest
akkeylab
0
140
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Building an army of robots
kneath
306
46k
AI: The stuff that nobody shows you
jnunemaker
PRO
3
490
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
250
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
Embracing the Ebb and Flow
colly
88
5k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
My Coaching Mixtape
mlcsv
0
87
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
290
The agentic SEO stack - context over prompts
schlessera
0
720
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
320
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
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/