图像的标准化 [英] Normalization of an image

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

问题描述

我在灰度图像上应用了一些操作,现在我得到了新值,但问题是强度值现在小于0,0到255之间且大于255.对于[之间的值0-255 ]没有问题,但强度值<1。 0和强度值> 255存在问题,因为这些值不能出现在灰度图像中。

I applied some operations on a grayscale image and now I am getting new values but the problem is the intensity values are now less than 0, between 0 and 255 and greater than 255. For values between [0-255] there is no problem but for intensity values < 0 and intensity values > 255 there is a problem as these values cannot occur in a grayscale image.

因此,我需要对这些值进行标准化,以使所有值无论是负数还是大于255或其他任何值,都在0到255范围内,所以可以显示图像。

Therefore, I need to normalize the values so that all the values whether they are negative or greater than 255 or whatever other values are, comes in the range 0 to 255 so that the image can be displayed.

为此,我知道两种方法:

For that I know two methods:

newImg = ((255-0)/(max(img(:))-min(img(:))))*(img-min(img(:)))

其中 min(img(:)) max(img(:))是对输入图像执行某些操作后获得的最小值和最大值 img min 可以小于0, max 可以大于255。

where min(img(:)) and max(img(:)) are the minimum and maximum values obtained after doing some operations on the input image img. The min can be less than 0 and the max can be greater than 255.

我只是将小于0的所有值设为0,将所有大于255的值设为255,所以:

I just make all the values less than 0 as 0 and all the values greater than 255 as 255, so:

img(img < 0) = 0;
img(img > 255) = 255;

我尝试使用这两种方法但是我使用第二种方法获得了良好的结果但是没有使用第一种方法一。谁能告诉我这是什么问题?

I tried to use both the methods but I am getting good results using second method but not with the first one. Can anyone of you please tell me what the problem is?

推荐答案

这完全取决于图像内容本身。这两种方法都有效,以确保值范围介于 [0,255] 之间。但是,在您决定使用何种方法之前,您需要问自己以下问题:

That totally depends on the image content itself. Both of those methods are valid to ensure that the range of values is between [0,255]. However, before you decide on what method you're using, you need to ask yourself the following questions:

您需要问的第一个问题是你的图像代表什么?例如,如果这是边缘检测器的输出,则您选择的方法将取决于结果中看到的值的动态范围(更多内容见问题#2)。例如,如果像素分布良好且方差较小,则最好使用第二种方法。但是,如果动态范围稍微小一些,那么您将需要使用第一种方法来提高结果的对比度。

The first question you need to ask is what does your image represent? If this is the output of an edge detector for example, the method you choose will depend on the dynamic range of the values seen in the result (more below in Question #2). For example, it's preferable that you use the second method if there is a good distribution of pixels and a low variance. However, if the dynamic range is a bit smaller, then you'll want to use the first method to push up the contrast of your result.

如果输出是图像减法,然后最好使用第一种方法,因为你想要可视化像素之间的确切差异。截断结果不会很好地显示差异。

If the output is an image subtraction, then it's preferable to use the first method because you want to visualize the exact differences between pixels. Truncating the result will not give you a good visualization of the differences.

您需要注意的另一件事是有多宽最小值和最大值的动态范围。例如,如果最小值和最大值与 [0,255] 的限制相差不远,那么您可以使用第一种或第二种方法,您将不会注意到差异。但是,如果您的值在 [0,255] 范围内的小范围内,则执行第一种方法将增加对比度,而第二种方法将不会执行任何操作。如果你的目标是增加图像的对比度,如果强度在有效的 [0,255] 范围内,那么你应该做第一种方法。

Another thing you need to take note of is how wide the dynamic range of the minimum and maximum values are. For example, if the minimum and maximum are not that far off from the limits of [0,255], then you can use the first or second method and you won't notice much of a difference. However, if your values are within a small range that is within [0,255], then doing the first method will increase contrast whereas the second method won't do anything. If it is your goal to also increase the contrast of your image and if the intensities are within the valid [0,255] range, then you should do the first method.

但是,如果您的最小值和最大值远离 [0,255] 范围,例如 min = -50 max = 350 ,然后做第一种方法不会很好 - 特别是如果灰度强度有很大差异。我的意思是巨大的差异是你会有高范围的值,低范围的值,没有别的。如果你使用第一种方法重新缩放,这意味着最小值被推到0,最大值缩小到255,其余强度在两者之间缩放,因此对于那些较低的值,它们会被缩放以便它们'重新显示为灰色。

However, if you have minimum and maximum values that are quite far away from the [0,255] range, like min=-50 and max=350, then doing the first method won't bode very well - especially if the grayscale intensities have huge variance. What I mean by huge variance is that you would have values that are in the high range, values in the low range and nothing else. If you rescaled using the first method, this would mean that the minimum gets pushed to 0, the maximum gets shrunk to 255 and the rest of the intensities get scaled in between so for those values that are lower, they get scaled so that they're visualized as gray.

这是没有多少人想到的东西。你的形象很干净,还是有几个虚假的嘈杂斑点?当涉及到噪声像素时,第一种方法非常糟糕。如果您只有几个像素值具有非常大的值但其他像素在 [0,255] 的范围内,这将使所有其他像素获得相应地重新缩放,因此会降低图像的对比度。您可能希望忽略这些像素所做的贡献,因此第二种方法更可取。

This is something that not many people think about. Is your image very clean, or are there a couple of spurious noisy spots? The first method is very bad when it comes to noisy pixels. If you only had a couple of pixel values that have a very large value but the other pixels are within the range of [0,255], this would make all of the other pixels get rescaled accordingly and would thus decrease the contrast of your image. You probably want to ignore the contribution made by these pixels and so the second method is preferable.

因此,您所谈论的这两种方法都没有错。您需要了解图像是什么,检查输出后看到的值的动态范围以及这是否是清晰或嘈杂的图像。你只需要做出明智的选择,牢记这两个因素。所以在你的情况下,第一个输出可能不起作用,因为你有非常大的负值和大的正值,也许这些值也很少。对你的应用程序进行截断可能更好。

Therefore, there is nothing wrong with either of those methods that you have talked about. You need to be cognizant of what the image is, the dynamic range of values that you see once you examine the output and whether or not this is a clear or noisy image. You simply have to make a smart choice keeping those two factors in mind. So in your case, the first output probably didn't work because you have very large negative values and large positive values and perhaps very few of those values too. Doing a truncation is probably better for your application.

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

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