如何在USM锐化工作? [英] How does an unsharp mask work?

查看:113
本文介绍了如何在USM锐化工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩弄图像处理最近,我想知道如何USM锐化算法的工作。我期待在源$ C ​​$下GIMP和它的实现,但到目前为止,我仍然在它是如何工作的黑暗。我需要实现它的一个项目,我的工作,但我想真正了解我使用的算法。

I've been playing around with image processing lately, and I'd like to know how the unsharp mask algorithm works. I'm looking at the source code for Gimp and it's implementation, but so far I'm still in the dark about how it actually works. I need to implement it for a project I'm working on, but I'd like to actually understand the algorithm I'm using.

推荐答案

我不知道它是如何工作要么但碰到一对真正的好页理解它。基本上它是这样的:

I wasn't sure how it worked either but came across a couple of really good pages for understanding it. Basically it goes like this:

  1. 什么是锐化图像相反?一个模糊的。我们知道如何模糊的图像。复制原始图象并执行一些高斯模糊。这是的半径的大多数USM对话框滑块。
  2. 那么,如果我们扣除掉模糊,我们应该与那些高对比度的部分留下!想想看:如果你模糊一片天空,但它仍然看起来像一个天空。减去像素,你会得到的天空 - 天空= 0。如果模糊可乐标志,你会得到一个模糊的可口可乐标志。减去它,留给你的边缘。所以,做的差
  3. 那么是什么让事情看起来更清晰?对比。再次重复原始图像和增加对比度。通过它,你增加对比度的金额是金额强度的滑块上最USM对话框。
  4. 最后把它放在一起。你有三样东西在这一点:

  1. What's the opposite of a sharpened image? A blurry one. We know how to blur an image. Duplicate the original image and perform some Gaussian blurring. This is the Radius slider on most USM dialogs.
  2. Well, if we subtract away the blurriness, we should be left with the parts that are high-contrast! Think about it: if you blur a sky, it still looks like a sky. Subtract the pixels and you get sky - sky = 0. If you blur a Coke logo, you get a blurry Coke logo. Subtract it and you're left with the edges. So do the difference
  3. Well what makes things look sharper? Contrast. Duplicate the original image again and increase the contrast. The amount by which you increase the contrast is the Amount or Intensity slider on most USM dialogs.
  4. Finally put it all together. You have three things at this point:

  1. 您的原始图像的高对比度版本
  2. 模糊图像的差异,你原来的(这一层主要是黑色)。这一层是 USM锐化

该算法是这样的:看从USM锐化像素,并找出它的光度(亮度)。如果发光度为100%,使用值从高对比度图像的该像素。如果它是0%时,使用该值从原始图像的该像素。如果它是介于两者之间的,使用一些权重混合使用这两种像素的值。或者,只改变像素的值,如果它的变化超过一定金额(这是大多数USM对话框中的阈值的滑块)。

The algorithm goes like this: Look at a pixel from the unsharp mask and find out its luminosity (brightness). If the luminosity is 100%, use the value from the high-contrast image for this pixel. If it is 0%, use the value from the original image for this pixel. If it's somewhere in-between, mix the two pixels' values using some weighting. Optionally, only change the value of the pixel if it changes by more than a certain amount (this is the Threshold slider on most USM dialogs).

把它放在一起,你有你的形象!

Put it all together and you've got your image!

下面是一些伪code:

Here's some pseudocode:

color[][] usm(color[][] original, int radius, int amountPercent, int threshold) {
  // copy original for our return value
  color[][] retval = copy(original);

  // create the blurred copy
  color[][] blurred = gaussianBlur(original, radius);

  // subtract blurred from original, pixel-by-pixel to make unsharp mask
  color[][] unsharpMask = difference(original, blurred);

  color[][] highContrast = increaseContrast(original, amountPercent);

  // assuming row-major ordering
  for(int row = 0; row < original.length; row++) {
    for(int col = 0; col < original[row].length; col++) {
       color origColor = original[row][col];
       color contrastColor = highContrast[row][col];

       color difference = contrastColor - origColor;
       float percent = luminanceAsPercent(unsharpMask[row][col]);

       color delta = difference * percent;

       if(abs(delta) > threshold)
         retval[row][col] += delta;
    }
  }

  return retval;
}

注意:我没有图形专家,但是这是我能够从我发现网页学习。阅读他们自己,确保你同意我的结论,但实现上述应该足够简单,所以给它一个镜头!

Note: I'm no graphics expert, but this is what I was able to learn from the pages I found. Read them yourself and make sure you agree with my findings, but implementing the above should be simple enough, so give it a shot!

    使用USM锐化
  • 锐化
  • <一个href="http://www.luminous-landscape.com/tutorials/understanding-series/understanding-usm.shtml">Understanding数字USM锐化
  • 3.7 USM锐化
  • 模糊掩蔽
  • Sharpening Using an Unsharp Mask
  • Understanding the Digital Unsharp Mask
  • 3.7 Unsharp Mask
  • Unsharp masking

这篇关于如何在USM锐化工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆