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

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

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

Tomoki Kobayashi

July 30, 2016
Tweet

More Decks by Tomoki Kobayashi

Other Decks in Programming

Transcript

  1. ৞ΈࠐΈΧʔωϧ         

    ೖྗը૾                          ग़ྗ  º º º º º º º º º × º 
  2. Ψ΢γΞϯΧʔωϧº         

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

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

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

    of image ) { for ( x of kernel ) { for ( y of kernel ) { for ( channel ) { operation } } } } }
  6. ී௨ͷ৐ࢉ 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]; }
  7. "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
  8. (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-Ͱ͕Μ͹ͬͯ·͢
  9. $*'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; ˞ΧʔωϧαΠζ͕ෆ໌ͷͨΊຊདྷൺֱ͢΂͖Ͱ͸ͳ͍͕ʜ
  10. 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);
  11. ͪͳΈʹ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);