Comments (5)
ガウスぼかしについて:
簡単にガウスぼかしを用いたモザイク処理について実装してみたところ、ガウスぼかしのカーネルサイズを変えただけではカーネルサイズをかなり大きくしないとボケてくれない+カーネルサイズを大きくすると実行に膨大な時間がかかるので、再帰的にガウスぼかしを呼び出して実装しました。
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('draemon.png')
h, w, c = img.shape
level = 10
resize = cv2.resize(img, (int(w*100/h), 100))
dst = resize
for i in range(1,level):
dst = cv2.GaussianBlur(dst,(5,5),10)
また、levelが一緒でも画素数によってぼかしの強さが変わってしまうので、一度リサイズして縦100ピクセルに調整する処理を受け取った画像に対して行っています。
一連の操作のなかで必要になった変数はlevelのみ。反復処理の回数指定に用いるので、整数型。値の範囲は10~100程度。
from tus-image-project.
ピクセルモザイクについて:
実装は以下。一度画像を縮小して、nearest neighborによって補完。例によって一度画像を縦100pxにリサイズしてから戻している。
img = cv2.imread('draemon.png')
h, w, c = img.shape
level = 10
resize = cv2.resize(img, (int(w*100/h) // level, 100 // level), interpolation=cv2.INTER_NEAREST)
dst = cv2.resize(resize, (w, h), interpolation=cv2.INTER_NEAREST)
ここでも必要になったパラメータはlevelのみ。値域は2~10程度。
from tus-image-project.
ぼかしフィルター=ガウスぼかしについて。
改めてガウスぼかしについて調べたところ、ガウスぼかしは一般的に、「ノイズ除去」を目的とした処理に使われ、ぼかしの強度を上げてもエッジが残りやすい性質があるみたい(畳み込み演算を行うとき、注目画素付近の重みが大きいため)。
今回の目的は平滑化を通して「顔を隠す」ことにあるため、平均フィルタを用いる方が適当なのかも。
加えて、ここでもし平均フィルタを使うのであれば、
class boxFilterStyle(AbstructMosaicStyle):
def __init__(self, kernel_size):
self.kernel_size = kernel_size
のようになるのかな? 実際、cv2の平均フィルタを呼び出す際は
blur = cv2.blur(img,(5,5)) #(img, (kernel_width, kernel_height))
となるので
from tus-image-project.
@k1105
しかし、サンプルから見ると、平均フィルタあまり効果がないようだが。エッジが残りやすいとは具体的にどのようになるか。確かに、モザイク自身のエッジが強くなるかもしれない、これをある程度の過渡の処理で弱くなれるでしょうか
また、画像処理の授業では、平均フィルタはノイズ除去に使われていると説明しているが。もちろんフィルターを一つに限定しなくてもいい、複数の組み合わせてもいけると思う
from tus-image-project.
from tus-image-project.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tus-image-project.