1. ホーム
  2. スクリプト・コラム
  3. パイソン

画像に自動的に虹の効果を加えるOpenCVの例

2022-01-25 13:41:50

背景

南の国の冬はいつも雨で、晴れの日は贅沢なものになりつつあります。そんな時、たとえ雨でも夏の暖かさを感じ、時には虹を見たい!とどんなに思ったことでしょう。そこで、夏の写真や動画を探して、OpenCVで虹を付けてみました。

 実装までの手順

[1] 夏景色の画像を用意し、ロードして読み込む

ciscoasa# show running-config
: Saved
:
ASA Version 8.4(2)
!
hostname ciscoasa
enable password 8Ry2YjIyt7RRXU24 encrypted
passwd 2KFQnbNIdI.2KYOU encrypted
names
!
interface GigabitEthernet0
nameif Intside
security-level 0
ip address 192.168.10.254 255.255.255.0
!
interface GigabitEthernet1
nameif outside
security-level 0
ip address 192.168.20.254 255.255.255.0
!
interface GigabitEthernet2
shutdown
no nameif
no security-level
no ip address
no ip address !
interface GigabitEthernet3
shutdown
no nameif
no security-level
no ip address
no ip address !
interface GigabitEthernet4
shutdown
no nameif
no security-level
no ip address
no ip address !
interface GigabitEthernet5
shutdown
no nameif
no security-level
no ip address
no ip address !
ftp mode passive
pager lines 24
mtu Intside 1500
mtu outside 1500
icmp unreachable rate-limit 1 burst-size 1
no asdm history enable
arp timeout 14400
timeout xlate 3:00:00
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 icmp 0:00:02
timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
timeout tcp-proxy-reassembly 0:01:00
timeout floating-conn 0:00:00
dynamic-access-policy-record DfltAccessPolicy
no snmp-server location
no snmp-server contact
snmp-server enable traps snmp authentication linkup linkdown coldstart warmstart
telnet timeout 5
ssh timeout 5
console timeout 0
threat-detection basic-threat
threat-detection statistics access-list
no threat-detection statistics tcp-intercept
!
class-map inspection_default
match default-inspection-traffic
!
!
policy-map type inspect dns preset_dns_map
parameters
message-length maximum client auto
message-length maximum 512
policy-map global_policy
class inspection_default
inspect dns preset_dns_map
inspect ftp
inspect h323 h225
inspect h323 ras
inspect rsh
inspect rtsp
inspect esmtp
inspect sqlnet
inspect skinny
inspect sunrpc
inspect xdmcp
inspect sip
inspect netbios
inspect tftp
inspect ip-options
!
service-policy global_policy global
prompt hostname context
crashinfo save disable
Cryptochecksum:715f838bf34db00a308a613eb31214ac
: end
ciscoasa# conf t
ciscoasa(config)# in g0
ciscoasa(config-if)# no na
ciscoasa(config-if)# no nameif Intside
ciscoasa(config-if)# nameif inside
INFO: Security level for "inside" set to 100 by default.
ciscoasa(config-if)# --
^
ERROR: % Invalid input detected at '^' marker.
ciscoasa(config-if)#
ciscoasa(config-if)# qq
^
ERROR: % Invalid input detected at '^' marker.
ciscoasa(config-if)# q
ciscoasa(config)# q
ciscoasa# show rou
ciscoasa# show route
ciscoasa# show run
ciscoasa# show running-config
: Saved
:
ASA Version 8.4(2)
ciscoasa# show run
hostname ciscoasa
enable password 8Ry2YjIyt7RRXU24 encrypted
passwd 2KFQnbNIdI.2KYOU encrypted
names
!
interface GigabitEthernet0
nameif inside
security-level 100
ip address 192.168.10.254 255.255.255.0
!
interface GigabitEthernet1
nameif outside
security-level 0
ip address 192.168.20.254 255.255.255.0
!
interface GigabitEthernet2
shutdown
no nameif
no security-level
no ip address
no ip address !
interface GigabitEthernet3
shutdown
no nameif
no security-level
no ip address
no ip address !
interface GigabitEthernet4
shutdown
no nameif
no security-level
no ip address
no ip address !
interface GigabitEthernet5
shutdown
no nameif
no security-level
no ip address
no ip address !
ftp mode passive
pager lines 24
mtu inside 1500
mtu outside 1500
icmp unreachable rate-limit 1 burst-size 1
no asdm history enable
arp timeout 14400
timeout xlate 3:00:00
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 icmp 0:00:02
timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
timeout tcp-proxy-reassembly 0:01:00
timeout floating-conn 0:00:00
dynamic-access-policy-record DfltAccessPolicy
no snmp-server location
no snmp-server contact
snmp-server enable traps snmp authentication linkup linkdown coldstart warmstart
telnet timeout 5
ssh timeout 5
console timeout 0
threat-detection basic-threat
threat-detection statistics access-list
no threat-detection statistics tcp-intercept
!
class-map inspection_default
match default-inspection-traffic
!
!
policy-map type inspect dns preset_dns_map
parameters
message-length maximum client auto
message-length maximum 512
policy-map global_policy
class inspection_default
inspect dns preset_dns_map
inspect ftp
inspect h323 h225
inspect h323 ras
inspect rsh
inspect rtsp
inspect esmtp
inspect sqlnet
inspect skinny
inspect sunrpc
inspect xdmcp
inspect sip
inspect netbios
inspect tftp
inspect ip-options
!
service-policy global_policy global
prompt hostname context
crashinfo save disable
Cryptochecksum:b6be07c60b5c6f70fdd258745b715629


[2] 元画像と同じ大きさの黒い画像を作成し、draw ellipse関数で虹を描きます。

[Verbindung zu 192.168.20.1 durch fremden Host geschlossen]
R1#show run
R1#show running-config
Konfiguration aufbauen...
Aktuelle Konfiguration : 1164 Bytes
!
Version 12.4
service zeitstempel debug datetime msec
dienst zeitstempel log datumszeit msec
no service passwort-verschlüsselung
!
Hostname R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
speicher-größe iomem 5
no ip icmp rate-limit unerreichbar
ip tcp synwait-time 5
!
ip cef
no ip domain lookup
!
Schnittstelle Ethernet0/0
IP-Adresse 192.168.10.1 255.255.255.0
halb-duplex
!
Schnittstelle Ethernet0/1
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet0/2
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet0/3
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet1/0
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet1/1
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet1/2
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet1/3
no ip adresse
Herunterfahren
halb-duplex
!
no ip http server
no ip http secure-server
ip route 192.168.20.0 255.255.255.0 192.168.10.254
!
Kontroll-Ebene
!
Leitung con 0
exec-timeout 0 0
Privilegstufe 15
Protokollierung synchron
Leitung aux 0
Ausführungszeitlimit 0 0
Privilegstufe 15
Protokollierung synchron
Leitung vty 0 4
Anmeldung
!
!
end

[3] ガウシアンブラーで虹のエッジをソフトに変化させる

R2#show running-config
Bauen der Konfiguration...
Aktuelle Konfiguration : 1198 Bytes
!
Version 12.4
service zeitstempel debug datetime msec
dienst zeitstempel log datumszeit msec
no service passwort-verschlüsselung
!
Hostname R2
!
boot-start-marker
boot-end-marker
!
Freigabe Passwort 123
!
no aaa new-model
speicher-größe iomem 5
no ip icmp rate-limit unerreichbar
ip tcp synwait-time 5
!
!
ip cef
no ip domain lookup
!
Schnittstelle Ethernet0/0
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet0/1
ip adresse 192.168.20.1 255.255.255.0
halb-duplex
!
Schnittstelle Ethernet0/2
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet0/3
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet1/0
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet1/1
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet1/2
no ip adresse
Herunterfahren
halb-duplex
!
Schnittstelle Ethernet1/3
no ip adresse
Herunterfahren
halb-duplex
!
no ip http server
no ip http secure-server
ip route 192.168.10.0 255.255.255.0 192.168.20.254
!
Kontroll-Ebene
!
Leitung con 0
exec-timeout 0 0
Privilegstufe 15
Protokollierung synchron
Leitung aux 0
Ausführungszeitlimit 0 0
Privilegstufe 15
Protokollierung synchron
Leitung vty 0 4
Kennwort asd
Anmeldung

[4] 虹の画像と風景の画像の重ね合わせ(ポアソンブレンドでより良くなる)

addWeighted(srcImg, 1.0, img, 0.2, 0, dst);

テストのために画像をいくつか変更する。

これは、OpenCVは自動的に画像に虹の効果を追加することについてのこの記事の終わりです、より関連するOpenCVは自動的に画像コンテンツに虹を追加するスクリプト家の前の記事を検索してくださいまたは次の関連記事を閲覧し続けるあなたは、スクリプト家を支持することを願っています!.