hist seg, find peaks, tps, pava单调拟合, isotonic-regression,REGULARIZED DISCRETE OPTIMAL TRANSPORT
文章目錄
- 1. 相關內容
- 1.1 hist seg:
- 1.2 pava(parallel Pool Adjacent Violators)
- 1.3 TPS(thin plate splines)
- 2. 基于optimal transpoet的 color transfer
- 1. 相關文章
- 2. REGULARIZED DISCRETE OPTIMAL TRANSPORT 論文 損失
- 3. REGULARIZED DISCRETE OPTIMAL TRANSPORT 論文
1. 相關內容
1.1 hist seg:
scipy.signal.find_peaks(x, height=None, threshold=None, distance=None, prominence=None, width=None, wlen=None, rel_height=0.5, plateau_size=None)
scipy.signal.peak_prominences(x, peaks, wlen=None)
find_peaks函數解釋
peaks2, properties2 = signal.find_peaks(hist2, distance=5, prominence=mmax / 20, width=2, plateau_size=[0, 100])'''distance:兩個相鄰peak的最小橫軸距離頂的高度:prominence:突出的程度需滿足的條件(頂點一橫線,向下平移,直到與更高peak的邊交叉。 左右兩邊取更高的base)頂的寬度:width: 一半 prominence位置處的寬度plateau_size:允許的平頂的橫軸大小范圍, '''1.2 pava(parallel Pool Adjacent Violators)
What is isotonic regression?
What is nearly-isotonic regression?
很好的兩篇博客介紹,isotonic-regression 和 nearly-isotonic-regression,兩者的原理如下:前者是強約束,后者是損失函數懲罰
isotonic-regression 是從左向右遍歷, 遇到更小的則和當前的塊平均,平均后的結果小于更前一個的時候還要再求平均。
兩篇博客都提供了動圖,是很好的解釋。
數學解釋和實現介紹了相關數學原理。
scipy中的isotonic regression 函數 如何用python調用
中文解釋和博客:
https://github.com/endymecy/spark-ml-source-analysis/blob/master/%E5%88%86%E7%B1%BB%E5%92%8C%E5%9B%9E%E5%BD%92/%E4%BF%9D%E5%BA%8F%E5%9B%9E%E5%BD%92/isotonic-regression.md
https://cloud.tencent.com/developer/article/1815613
1.3 TPS(thin plate splines)
[薄板樣條插值(Thin Plate Spline)]https://zhuanlan.zhihu.com/p/227857813
介紹了數學原理推導
數值方法——薄板樣條插值(Thin-Plate Spline)
[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-O6SQm7iS-1681722986585)(2023-04-06-16-48-11.png)]
薄板樣條函數(Thin plate splines)的討論與分析
2d tps的數學原理概述,總的來說就是tps得到的結果會使整個曲面的彎曲能量最小:
薄板樣條插值(Thin plate splines)的實現與使用 pytorch 的實現,opencv的使用
opencv使用:
def tps_cv2(source, target, img):"""使用cv2自帶的tps處理"""tps = cv2.createThinPlateSplineShapeTransformer()source_cv2 = source.reshape(1, -1, 2)target_cv2 = target.reshape(1, -1, 2)matches = list()for i in range(0, len(source_cv2[0])):matches.append(cv2.DMatch(i,i,0))tps.estimateTransformation(target_cv2, source_cv2, matches)new_img_cv2 = tps.warpImage(img)return new_img_cv2pytorch實現:
def tps_torch(source, target, img, DEVICE):"""使用pyotrch實現的tps處理"""ten_img = ToTensor()(img).to(DEVICE)h, w = ten_img.shape[1], ten_img.shape[2]ten_source = norm(source, w, h)ten_target = norm(target, w, h)tpsb = TPS(size=(h, w), device=DEVICE)warped_grid = tpsb(ten_target[None, ...], ten_source[None, ...]) #[bs, h, w, 2](相對) 根據source、target得到的仿射函數,處理圖片ten_wrp = torch.grid_sampler_2d(ten_img[None, ...], warped_grid, 0, 0, False)new_img_torch = np.array(ToPILImage()(ten_wrp[0].cpu()))return new_img_torch2D tps code
3D tps:This is a Python reimplementation of the MATLAB version by Yang Yang
Thin Plate Spline
2. 基于optimal transpoet的 color transfer
1. 相關文章
2. REGULARIZED DISCRETE OPTIMAL TRANSPORT 論文 損失
損失目標是:
有點類似Partial optimal transport的損失,不過Partial optimal transport只包含了Kx, Ky的約束,未包含 kx, ky
此外Partial optimal transport 有ot.partial.entropic_partial_wasserstein 熵約束。
該論文提出了基于圖的梯度約束。
具體如下:
首先 假設我們想要的映射矩陣是 T(下面公式種的求和符號):X 轉換為 Y
Xi的的轉換為
為了凸優化:
然后構建一個圖, Xi最近的 K 個鄰居鏈接為邊。
每條邊的weight:
則 T在 Xi上的約束為:
所有邊的約束:
最終的損失函數:
3. REGULARIZED DISCRETE OPTIMAL TRANSPORT 論文
注意 transfer seg的方法
和 transfer pixel的方法
本文中的方法就是pot lib中 transform
其次 找到對應關系之后,可以用多項式擬合或者TPS來擬合。
Optimal Transportation for Example-Guided Color Transfer就是用tps擬合的
總結
以上是生活随笔為你收集整理的hist seg, find peaks, tps, pava单调拟合, isotonic-regression,REGULARIZED DISCRETE OPTIMAL TRANSPORT的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ubuntu软件:无法从“extensi
- 下一篇: android实现延时的方法,Andro