簡體   English   中英

如何使用CIFilter作為鏈接下的圖像創建失真效果

[英]How to create distortion effect using CIFilter as the images under link

我希望使用核心圖像濾鏡將效果添加到我的應用程序(Live Filtering Recorder App)中。 這種效果需要顯示出失真線,就像舊的錄音機一樣。 我嘗試通過加載圖像幀並將其作為疊加層應用到濾鏡圖像的輸出來進行嘗試,但這會給錄制造成延遲。 因此,我現在不希望通過CIFILTERS產生這種效果。

像變形線一樣的錄音機

謝謝。

這看起來像是自定義內核的工作。

您可以使用CIRandomGenerator生成一個隨機噪聲場,然后使用一些自定義的Core Image Kernel Language將其合成為原始條紋圖像,並使用sin控制間隔。 通過smoothstep傳遞垂直位置的smoothstep會產生很好的效果。

您的內核應類似於:

    let kernel = CIColorKernel(string:
        "kernel vec4 vhsNoise(__sample image, __sample noise, float time, float spacing, float stripeHeight, float backgroundNoise)" +
            "{" +
            "   vec2 uv = destCoord();" +

            "   float stripe = smoothstep(1.0 - stripeHeight, 1.0, sin((time + uv.y) / spacing)); " +

            "   return image + (noise * noise * stripe) + (noise * backgroundNoise);" +
        "}"
        )!

我實際上已經編寫了一個CIFilter來做到這一點,您可以在這里找到

西蒙

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM