计算图像梯度 [英] Calculating image gradient

查看:92
本文介绍了计算图像梯度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为您方便起见,我将其尽量缩短.我正在尝试计算某些图像渐变的每个像素的灰度值.

I'll make it short as possible for your convenience. I'm trying calculate the grey value of each pixel of some image's gradient.

据我所知,可以通过两种方法来计算G(x,y)(渐变图像中的像素x,y):

To my knowledge, G(x,y) (the pixel x,y in the gradient image) can be calculated in two ways:

1. G(x,y) = sqrt(dx(x,y) * dx(x,y) + dy(x,y) * (dy(x,y))
2. G(x,y) = |dx(x,y)| + |dy(x,y)|

我试图了解第一个结果如何导致[0,255]中的值,例如dx(x,y)= 255,dy(x,y)= 255将导致〜360,这未定义为灰度.

I'm trying to understand how the first one results in a value in [0, 255], for example dx(x,y) = 255, dy(x,y) = 255 will result in ~360, which is undefined in grey scale.

此外,第二种方法是如何定义的?| dx(x,y)|是什么意思当dx(x,y)属于[0,255]时,是否为正?

Also, how is the second method defined? what does it mean |dx(x,y)| when dx(x,y) belongs to [0, 255], thus positive?

谢谢!

推荐答案

这两种方法都不能保证每个像素都位于[0,255]中.如果您希望所有像素都在[0,255]中,则可能需要规范化找到渐变后的图像.

Neither method guarantees that each pixel will be in [0, 255]. If you want all pixels to be in [0, 255] you may need to normalize your image after finding the gradient.

第二种方法是绝对差之和.找到绝对值比求平方根快,因此方法2比方法1快.

The second method is the sum of the absolute difference. Finding an absolute value is faster than taking the square root so method 2 will be faster than method 1.

这篇关于计算图像梯度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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