Upgrade to Pro — share decks privately, control downloads, hide ads and more …

画像フィルタリング高速化するよ@iOS

 画像フィルタリング高速化するよ@iOS

0b8ad408b31cb9d5cff2828086c65d58?s=128

temoki

July 30, 2016
Tweet

Transcript

  1. ը૾ϑΟϧλϦϯά ߴ଎Խ͢ΔΑˏJ04 !UFNPLJ

  2.  ը૾ϑΟϧλϦϯάͬͯԿʁ  ը૾ϑΟϧλϦϯάͷ࣮૷  ը૾ϑΟϧλϦϯάΛߴ଎Խʂ

  3.  ը૾ϑΟϧλϦϯάͬͯԿʁ  ը૾ϑΟϧλϦϯάͷ࣮૷  ը૾ϑΟϧλϦϯάΛߴ଎Խʂ

  4. ͜ͷϨφ͞ΜࣸਅΛ

  5. ΅͔ͨ͠Γ

  6. ྠֲͱΓͩͨ͠Γ

  7. ϞβΠΫ ͔͚ͨΓ ͢Δ΍ͭͰ͢ ը૾αϯϓϧʮϨφʯͷਖ਼ମ͸ʮ1-":#0:ʯࢽͷ ࠷ଟൢച෦਺Λه࿥ͨ͠ϓϨΠϝΠτ IUUQHJHB[JOFOFUOFXT@MFOOB

  8.  ը૾ϑΟϧλϦϯάͬͯԿʁ  ը૾ϑΟϧλϦϯάͷ࣮૷  ը૾ϑΟϧλϦϯάΛߴ଎Խʂ

  9. Ұൠతͳը૾σʔλ

  10. QJYFM 3(#"

  11. QJYFM 3FE(SFFO#MVF"MQIB νϟϯωϧʹόΠτʹdͷ஋ ܭνϟϯωϧʹόΠτ

  12. ը૾શମ 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#"

    3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#" 3(#"3(#"3(#"3(#"3(#"3(#"3(#"3(#"
  13. ৞ΈࠐΈԋࢉ

  14. ৞ΈࠐΈΧʔωϧ         

    ೖྗը૾                          ग़ྗ  º º º º º º º º º × º 
  15. ৞ΈࠐΈΧʔωϧ $POWPMVUJPO,FSOFM

  16. ྫ͑͹ɺ

  17. ΅͔͠ʢҠಈฏۉʣ         

  18. ΅͔͠ʢՙॏฏۉʣ         

  19. Τοδநग़ʢਫฏʣ         

  20. Τοδநग़ʢਨ௚ʣ         

  21. ઌӶԽ         

  22. αΠζ΋͍Ζ͍Ζ

  23. Ψ΢γΞϯΧʔωϧº         

    ˞ઌ΄Ͳͷʮ΅͔͠ʢՙॏฏۉʣʯͱಉ͡
  24. Ψ΢γΞϯΧʔωϧº         

                   
  25. Ψ΢γΞϯΧʔωϧº         

                                           
  26. ܭࢉྔ

  27. for ( x of image ) { for ( y

    of image ) { for ( x of kernel ) { for ( y of kernel ) { for ( channel ) { operation } } } } }
  28.  ສճͷԋࢉ w ೖྗը૾ɿ3(#"Y w ΧʔωϧɿΨ΢γΞϯΧʔωϧº w ºººº  

  29. ॲཧ࣌ؒ

  30. ͜ΜͳΞϓϦ ͭͬͯ͘ݕূ

  31. ໿'14 w σόΠεɿJ1IPOF w ೖྗը૾ɿ3(#"Y w ΧʔωϧɿΨ΢γΞϯΧʔωϧº

  32. ࢖͑ͨ΋Μ͡Όͳ͍ʜ

  33.  ը૾ϑΟϧλϦϯάͬͯԿʁ  ը૾ϑΟϧλϦϯάͷ࣮૷  ը૾ϑΟϧλϦϯάΛߴ଎Խʂ

  34. ߴ଎Խ w ΞϧΰϦζϜͷ޻෉ͰܭࢉྔΛݮΒ͢ w σόΠεͷܭࢉࢿݯΛ࠷େݶʹར༻

  35. ߴ଎Խ w ΞϧΰϦζϜͷ޻෉ͰܭࢉྔΛݮΒ͢ w σόΠεͷܭࢉࢿݯΛ࠷େݶʹར༻ ˠͪ͜Β͕͜ͷεϥΠυͷςʔϚͰ͢ɻ

  36. ϚϧνίΞ w ը૾Λෳ਺ͷΤϦΞʹ෼ׂ͢Δ
 ʢྫʣը૾ͷࠨ൒෼ͷӈ൒෼ w σόΠεͷίΞ਺෼εϨουΛ࡞੒͠
 ֤εϨουʹΤϦΞΛׂΓ౰ͯΔ

  37. ˣ'14ˣ w J1IPOF͸ίΞˠεϨου w εϨουॲཧ͸($%Ͱ؆୯ʹ w εϨουͷΦʔόʔϔου͕େ͖͍ʁ
 ΋ͬͱ͕Μ͹ΕΔ͸ͣʜ w ͞ΕͲίΞͰ͸خ͠͞͸ബ͍

  38. 4*.% w 4JOHMF*OTUSVDUJPO.VMUJQMF%BUB w ౓ͷ໋ྩͰෳ਺ͷσʔλΛԋࢉ w ϕΫτϧԋࢉɺύοΫυԋࢉ w $16ͷ֦ு໋ྩͱͯ͠
 Yͷ..944&౳

    "3.ͷ/&0/
  39. ී௨ͷ৐ࢉ int a[4] = { 1, 2, 3, 4 };

    int b[4] = { 5, 6, 7, 8 }; int c[4]; for ( int i=0; i<4; i++) { c[i] = a[i] * b[i]; }
  40. "3./&0/Ͱ৐ࢉ ʢίϯύΠϥ૊ΈࠐΈؔ਺ʣ int32_t a = { 1, 2, 3, 4

    }; int32_t b = { 5, 6, 7, 8 }; int32_t c; c = vmulq_s32( a, b ); IUUQXXXBSNDPNKBQSPEVDUTQSPDFTTPSTUFDIOPMPHJFTOFPOQIQ
  41. ˢ'14ˢ w গ͠଎͘ͳͬͨʁ w ॲཧΛ࠷దԽ͢Ε͹΋ͬͱ͍͚Δʁ

  42. ͦͯ͠ɺϝχʔίΞ΁

  43. ϚϧνίΞ $PSF $PSF $PSF $PSF γϯάϧίΞ $PSF ϝχʔίΞ

  44. ϝχʔίΞ w େྔͷίΞΛ࣋ͭϓϩηοαͰܭࢉ w (16/7*%*" ".% *OUFM *NBHJOBUJPO w *OUFM9FPO1IJ

  45. (16Ͱը૾ॲཧ!J04 w J1IPOFͷ(16͸1PXFS73 w $PSF*NBHFGSBNFXPSLͷ$*'JMUFS w "DDFMFSBUFGSBNFXPSLͷW*NBHF w 0QFO$-ʢJ04Ͱ͸࢖͍෺ʹͳΒͳ͍ʣ w

    0QFO(-(-4-Ͱ͕Μ͹Δʢ໘౗ʜʣ 6*&WPMVUJPOதౡ૱ࢯͷ7JEFP4IBEFSΞϓϦ΍(16*NBHFϥΠϒϥϦ͸(-4-Ͱ͕Μ͹ͬͯ·͢
  46. $*'JMUFS ˢˢ'14ˢˢ ௒଎ʂ CIImage * src = [CIImage imageWithCVPixelBuffer:imageBuffer]; CIFilter

    * filter = [CIFilter filterWithName:@"CIGaussianBlur"]; [filter setValue:src forKey:@"inputImage"]; [filter setValue:[NSNumber numberWithFloat:1.f] forKey:@"inputRadius"]; CIImage * dst = filter.outputImage; ˞ΧʔωϧαΠζ͕ෆ໌ͷͨΊຊདྷൺֱ͢΂͖Ͱ͸ͳ͍͕ʜ
  47. W*NBHF ˢˢˢ'14ˢˢˢ ര଎ʂ const vImage_Buffer src = { CVPixelBufferGetBaseAddress(buffer), height,

    width, bytesPerRow }; const vImage_Buffer dst = { malloc(bufferSize), height, width, bytesPerRow }; Pixel_8888 backgroundColor = {0,0,0,0}; vImageConvolve_ARGB8888(&src, &dst, NULL, 0, 0, gaussianKernel, 7, 7, divisor, backgroundColor, kvImageCopyInPlace);
  48. (16࢖͏Ͱ͠ΐʂ

  49. ͪͳΈʹ0QFO$7 ˠ'14 w ී௨ʹ$16Ͱԋࢉ w $6%"࣮૷͕͋ΔΒ͍͠HQV(QV.BU w 0QFO$-࣮૷͕͋ΔΒ͍͠PDM.BU cv::Mat src

    = cv::Mat(height, width, CV_8UC4, baseAddress); cv::Mat dst = cv::Mat(height, width, CV_8UC4); cv::Size kernelSize(7, 7); cv::GaussianBlur(src, dst, kernelSize, 1.f);
  50. ͓ΘΓ