最快的高斯模糊(線性時間)Fastest Gaussian Blur (in linear time)
I needed really fast Gaussian blur for one of my projects. After hours of struggling and browsing the internet, I finally found the best solution.
Beginning
My solution is based on Fast image convolutions by Wojciech Jarosz. Presented ideas are very simple and I don't know
who is the original author. I am going to describe it a little better and add some mathematics. To get motivated, take a glance at
Definition
The convolution of two 2D functions
The Gaussian blur of a 2D function can be defined as a convolution of that function with 2DGaussian function. Our gaussian function
has an integral 1 (volume under surface) and is uniquely defined by one parameter
In our discrete finite case, we represent our 2D functions as matrices of values. We compute the volume (integral) as a sum. Gaussian function has near to zero values behind some radius, so we will use only the values
Algorithm 1
For a general discrete convolution of
For gaussian weight, we can compute only weights around [i, j] (area of
// source channel, target channel, width, height, radius function gaussBlur_1 (scl, tcl, w, h, r) { var rs = Math.ceil(r * 2.57); // significant radius for(var i=0; i<h; i++) for(var j=0; j<w; j++) { var val = 0, wsum = 0; for(var iy = i-rs; iy<i+rs+1; iy++) for(var ix = j-rs; ix<j+rs+1; ix++) { var x = Math.min(w-1, Math.max(0, ix)); var y = Math.min(h-1, Math.max(0, iy)); var dsq = (ix-j)*(ix-j)+(iy-i)*(iy-i); var wght = Math.exp( -dsq / (2*r*r) ) / (Math.PI*2*r*r); val += scl[y*w+x] * wght; wsum += wght; } tcl[i*w+j] = Math.round(val/wsum); } }
Algorithm 2
Let's introduce the box blur. It is the convolution of function
In this algorithm, we will simulate the gaussian blur with 3 passes of box blur. Let's denote the half of size of square as
We have to convert the standard deviation of gaussian blur
I needed really fast Gaussian blur for one of my projects. After hours of struggling and browsing the internet, I finally found the be
img標籤新增class 設定filter:blur (0-npx)模糊半徑
filter: url(blur.svg#blur); /* FireFox, Chrome, Opera */
最近在做一個這樣一個需求,一個控制元件可以實時預覽攝像頭的內容,並且對此影象進行高斯模糊處理,現在來記錄一下。
基本的實現思路
1,攝像頭實時預覽的資料會回撥給onPreviewFrame(byte[] data, Camera camera) ,通過這個獲取YU
本人是影象處理的初學者,在http://www.cnblogs.com/Imageshop/p/3145216.html博文中看到有關影象柔光的特效處理原理後自己也動手實現了一下,這裡包括一個快速高斯模糊的演算法,具體原理可以參考論文《Recursive Imp Shader "PengLu/ImageEffect/Unlit/GaussianBlur" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
CGINCLUDE
#include "UnityCG.cginc"
s /*** 高斯模糊* @param bkg* @param view*/private void blur(Bitmap bkg, View view) {float radius = 25;Bitmap overlay = Bitmap.createBitmap((int) (view.getMeasure
通常,影象處理軟體會提供”模糊”(blur)濾鏡,使圖片產生模糊的效果。
根據官方的帖子實現的高斯模糊當前螢幕內容 點選開啟連結
1.截圖縮小壓縮,減小畫素取樣的優化演算法。預設截圖後縮小到原來的1/4。
2.C++程式碼進行一次性高斯模糊。避免使用shader造成的渲染掉幀
以下是C++部分程式碼:
/*
* 高斯模糊介面 縮放因
毛玻璃效果相信很多朋友都眼紅很久了,
隔壁ios系統對高斯模糊早就大範圍使用了,
咱們Android卻絲毫不為所動,
於是就只能靠廣大開發者咯。
這是目前市面上效能最高的方案,
也不知道最初是 std 回來 int 沒有 moto ext pri 線性 inf 傳送門
首先看到異或就想到線性基
我們考慮有一條路徑,那麽從這條路徑走到圖中的任意一個環再走回這條路徑上,對答案的貢獻是這個環的異或和,走到這個環上的路徑對答案是沒有影響的
以這張(偷來的)圖為
本文作者:小嗷
微信公眾號:aoxiaoji
吹比QQ群:736854977
本文你會找到以下問題的答案:
方差
標準差
數學期望
正態分佈
高斯函式
2.1 方差
方差描述隨機變數對於數學期望的偏離程度。(隨機變數可以
用牛頓法求解代價函式的最小值,這裡是n維向量,是實數。
解 牛頓法(詳細點此)迭代公式為,
這裡,是關於的偏導數向量;是一個n
x n被稱作Hessian的矩陣,其元素為。
先求關於的偏導數
上式
高斯濾波簡介: 高斯濾波是通過對輸入陣列的每個點與輸入的高斯濾波模板執行卷積計算然後將這些結果一塊組成了濾波後的輸出陣列,通俗的講就是高斯濾波是對整幅影象進行加權平均的過程,每一個畫素點的值都由其本身和鄰域內的其他畫素值經過加權平均後得到。
高斯
的系列文章進行學習。
不過博主的部落格只寫到“第十講 資料降維” http://blog.csdn.net/abcjennifer/article/details/8002329,後面還有三講,內容比較偏應用,分別是異常檢測、大資料機器學習、photo OCR。為了學習的完整性,我將把後續三講的內容補充
1:高斯模糊演算法(參考:http://www.ruanyifeng.com/blog/2012/11/gaussian_blur.html)
所謂的模糊演算法就是當前畫素點和周圍畫素點進行加權均值之後的結果替換當前畫素值。因此均值模糊是最簡單的,只要將周圍的畫素點
程式碼如下:
# 匯入cv模組
import cv2 as cv
import numpy as np
# 確保在0-255之間
def clamp(pv):
if pv > 255:
return 255
if pv < 0:
r
理論知識:
參考連結:
對Photoshop高斯模糊濾鏡的演算法總結:http://www.cnblogs.com/hoodlum1980/archive/2008/03/03/1088567.html
Python計算機視覺3:模糊,平滑,去噪:https://www.cnblogs.
SIFT演算法是在不同的尺度空間上查詢關鍵點,而尺度空間的獲取需要使用高斯模糊來實現 。
一維正態分佈公式:
(x-μ)在高斯影象模糊中對應模糊半徑,指的是模板元素到模板中心的距離。
eg: 二維模板大小為m*n,則
Glide中MultiTransformation使用
MultiTransformation可以實現多個Transformation效果結合實現一些需求
1、例如Glide載入一張圖片,我們需要把這張
傳送門
解析:
先求一個線性基,然後高斯消元解線性空間,然後基本上就是亂搞把第
k
k
k 相關推薦
最快的高斯模糊(線性時間)Fastest Gaussian Blur (in linear time)
簡單css實現高斯模糊(毛玻璃效果)
Android 實時濾鏡 高斯模糊(帶原始碼)
快速高斯模糊(IIR遞迴高斯模糊)
UnityShader例項14:螢幕特效之高斯模糊(Gaussian Blur)
Android實現高斯模糊(也叫毛玻璃效果)
高斯模糊(高斯濾波)的原理與演算法
cocos2dx 高效能高斯模糊(包含lua介面)
Android簡單、高效能的高斯模糊(毛玻璃)效果(附原始碼)
洛谷P4151 [WC2011]最大XOR和路徑(線性基)
20.方差/標準差/數學期望/正態分佈/高斯函式(數學篇)--- OpenCV從零開始到影象(人臉 + 物體)識別系列
牛頓法求解最小二乘問題(線性迴歸)
CUDA實現影象的高斯濾波(opencv實現)
機器學習-多元高斯分佈(異常檢測)
最快速的“高斯”模糊演算法(附Android原始碼)
opencv學習(十一):高斯模糊
opencv學習(十):高斯模糊理論知識
SIFT(2)-----高斯模糊
Glide中MultiTransformation使用,實現多種變換效果組合(圓形,圓角,高斯模糊,黑白...)
2018.12.07【LOJ114】k 大異或和(線性基)(高斯消元)