$30 off During Our Annual Pro Sale. View Details »

20181130.pdf

sug1t0m0
December 20, 2018

 20181130.pdf

sug1t0m0

December 20, 2018
Tweet

More Decks by sug1t0m0

Other Decks in Technology

Transcript

  1. ͜͜Λ͜͏ͨ͠Β଎͘ͳͬͨ!! (OpenCVͷαϯϓϧίʔυΛ ίϐϖ͹͔Γ͍ͯͨ͠๻͕ ؾ͍ͮͯΑ͔ͬͨͱࢥ͏͜ͱ) Sugiyama.T (@sug1t0m0_agrict) #WaterCell Tech Night #2

  2. Python OpenCVͷجૅ ըૉ΁ͷΞΫηε (άάΔͱ͙͢ʹग़ͯ͘Δ΍ͭ) • ըૉ͝ͱʹ৭Λऔಘ͢Δ blue = img[10, 20,

    0] green = img[10, 20, 1] red = img[10, 20, 2] pixelValue = img[Y࠲ඪ, X࠲ඪ, νϟϯωϧ] • ըૉͷॻ͖׵͑ img[10, 20, 0] = 255 img[10, 20, 1] = 255 img[10, 20, 2] = 255 img[10, 20] = [255, 255, 255] or
  3. Python OpenCVͷجૅ ըૉ΁ͷΞΫηε (NumpyΛ࢖͏ͱ) • img_1ͷըૉ(x,y)͕50Ҏ্ͷͱ͖ img_2ͷըૉ(x,y)ͷ஋Λ52ʹ͍ͨ͠ for y in

    range(height): for x in range(weight): if img_1[y, x, 0] >= 50 : img_2[y, x, 0] = 52 ɹɹɹɹɹɹɹɹɹɹɹɹɹͱ΍ͬͯ͠·͏ • Ͱ΋numpyΛ࢖͏ͱɺɺɺ cond = img_1 >= 50 img_2[cond] = 52 ɹɹɹɹɹɹɹɹɹɹͰɺ͍͚Δʂ
  4. ͬ͘͟Γ(͔ͳΓద౰ʹ)଎౓ൺֱ for y in range(height): for x in range(weight): if

    img_1[y, x, 0] >= 50 : img_2[y, x, 0] = 52 • time : 0.779437780380249[sec] cond = img_1 >= 50 img_2[cond] = 52 • time : 0.004307746887207031[sec] • Pythonͷfor͸஗͍ • ΠϯλϓϦλͷΦʔόʔϔουʁ • ੩తͳܕఆٛΛ࣋ͨͳ͍͔Βʁ
  5. ͜Ε͸Boolean Indexͱ͍͏΋ͷΒ͍͠ • numpyͷ഑ྻ͸ൺֱԋࢉࢠͰܭࢉΛߦ͏ͱਅ ِ஋ͷ഑ྻʹɺɺɺ • ্هͷਅِ஋ͷ഑ྻΛ࢖͏͜ͱͰɺըૉͷॻ ͖׵͕͑ߴ଎ʹߦ͑Δɺɺɺ  

           5 5 ' 5 ' 5 5 5 ' =< 2 img [ ]=2   EW W  EW    EW 5 5 ' 5 ' 5 5 5 '
  6. To দҪ͞Μ