OpenCV and Unsharp Masking Like Adobe Photoshop

前端 未结 3 2062
挽巷
挽巷 2021-02-06 19:11

I am trying to implement unsharp masking like it\'s done in Adobe Photoshop. I gathered a lot of information on the interent but I\'m not sure if I\'m missing something. Here\'s

3条回答
  •  自闭症患者
    2021-02-06 19:31

    I'm trying to replicate Photoshop's Unsharp Mask as well. Let's ignore the Threshold for a second.

    I will show you how to replicate Photoshop's Unsharp Mask using its Gaussian Blur.

    Assuming O is the original image layer.

    Create a new layer GB which is a Gaussian Blur applied on O.
    Create a new layer which is O - GB (Using Apply Image).
    Create a new layer by inverting GB - invGB.
    Create a new layer which is O + invGB using Image Apply.
    Create a new layer which is inversion of the previous layer, namely inv(O + invGB).
    Create a new layer which is O + (O - GB) - inv(O + invGB).

    When you do that in Photoshop you'll get a perfect reproduction of the Unsharp Mask.

    If you do the math recalling that inv(L) = 1 - L you will get that the Unsharp Mask is USM(O) = 3O - 2B.

    Yet when I do that directly in MATLAB I don't get Photoshop's results.

    Hopefully someone will know the exact math.

    Update

    OK,
    I figured it out.
    In Photoshop USM(O) = O + (2 * (Amount / 100) * (O - GB))
    Where GB is a Gaussian Blurred version of O.

    Yet, in order to replicate Photoshop's results you must do the steps above and clip the result of each step into [0, 1] as done in Photoshop.

提交回复
热议问题