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

20181130.pdf

sug1t0m0
December 20, 2018

 20181130.pdf

sug1t0m0

December 20, 2018
Tweet

More Decks by sug1t0m0

Other Decks in Technology

Transcript

  1. 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
  2. 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 ɹɹɹɹɹɹɹɹɹɹͰɺ͍͚Δʂ
  3. ͬ͘͟Γ(͔ͳΓద౰ʹ)଎౓ൺֱ 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͸஗͍ • ΠϯλϓϦλͷΦʔόʔϔουʁ • ੩తͳܕఆٛΛ࣋ͨͳ͍͔Βʁ