保留形状的形式如何缩小索引图像

As you know, in an index image, each pixel value indicates the code of a colour stored in a map, and index images are popular in various fields. Unfortunately, index image downscaling is very indispensable whereas we have not convenient tools for it in view of the fact that most downscaling methods are based on average. The question is how can we downscale an index image while preserving the form of shapes? I was involved with this problem for a while and found a solution.

众所周知,在索引图像中,每个像素值表示存储在地图中的颜色的代码,并且索引图像在各个领域都很流行。 不幸的是,索引图像缩小是非常必不可少的,但是鉴于大多数缩小方法都是基于平均值这一事实,我们没有便捷的工具。 问题是如何在保留形状形式的同时缩小索引图像? 我参与了这个问题一段时间,并找到了解决方案。

Suppose we have an index image like Figure 1, after downscaling with the nearest neighbour method we obtain Figure 2. As you see, the result is not acceptable because the form of the shapes have changed and the boundaries are separated.

假设我们有一个如图1所示的索引图像,使用最近的邻居方法进行缩小后,我们得到了图2。如您所见,结果是不可接受的,因为形状的形式已经改变并且边界被分离了。

Since we have a color palette (color map) for the index image, we know what colors exist in the image. The first step is to detect the color which presents in boundaries, for this purpose, we plot the color histogram and select the color which has the lowest value in the histogram. Most likely, the selected color is the boundaries color. Depending on the amount of image details, more complex methods may be required. Till here we know the color of boundaries.

由于我们有索引图像的调色板(颜色图),因此我们知道图像中存在什么颜色。 第一步是检测出现在边界中的颜色,为此,我们绘制颜色直方图并选择在直方图中具有最低值的颜色。 所选颜色很可能是边界颜色。 根据图像细节的数量,可能需要更复杂的方法。 直到这里我们知道边界的颜色。

In the next step, we downscale the main image using the nearest-neighbor method. This method leads to disconnecting borders and changing the form of shapes but guarantees the color map doesn’t change. We name this downscaled image the “corrupted” image. We will clone the main image and work on it, in the end, we merge the cloned image into the corrupted image to obtain a better result.

下一步,我们使用最近邻方法对主图像进行缩小。 此方法导致断开边界并更改形状的形式,但可以保证颜色图不变。 我们将此缩小的图像称为“损坏的”图像。 我们将克隆主映像并对其进行处理,最后,将克隆的映像合并到损坏的映像中以获得更好的结果。

In the cloned image, we keep only the boundary color and make other pixels black (now, the color map contains only 2 colors).

在克隆的图像中,我们仅保留边界颜色,而将其他像素设为黑色(现在,颜色图仅包含2种颜色)。

Image for post
Figure 3
图3

In the next step, we must binary the image with a suitable threshold.

下一步,我们必须使用适当的阈值对图像进行二值化。

Image for post
Figure 4
图4

In the next step, we downscale the binary image using the bilinear method. This method is based on averaging between surrounding pixels and preserve the forms better than the nearest-neighbor method but generates new colors and makes the binary image, a grayscale image(now, the color map contains more than 2 colors).

下一步,我们使用双线性方法缩小二进制图像的尺寸。 该方法基于周围像素之间的平均,并且比最近邻方法更好地保留形式,但是生成新的颜色并使二进制图像成为灰度图像(现在,颜色图包含两种以上的颜色)。

Image for post
Figure 5
图5

We must binary the image once again to ensure we have only black and white pixels (now, the color map contains 2 colors).

我们必须再次对图像进行二值化处理,以确保只有黑白像素(现在,颜色图包含2种颜色)。

Image for post
Figure 6
图6

The next step is the coloring of white pixels with the boundary color.

下一步是使用边界颜色为白色像素着色。

Image for post
Figure 7
图7

As you know, the boundaries make the shapes. In the corrupted image, we must change the boundaries color to a new temp color (which does not exist in the color map) because we want to modify the boundaries and the new boundaries (in the cloned image) may be thicker or thinner, then for each pixel in the cloned image which is not black, we change the color of the corresponding pixel in the corrupted image to boundaries color.

如您所知,边界构成形状。 在损坏的图像中,我们必须将边界颜色更改为新的临时颜色(颜色映射中不存在),因为我们要修改边界,并且新的边界(在克隆的图像中)可能更粗或更细,然后对于克隆图像中非黑色的每个像素,我们将损坏图像中相应像素的颜色更改为边界颜色。

Image for post
Figure 8
图8

Now in the corrupted image, the form of shapes is preserved and boundaries are not separated and we named this image, result image. If some pixels in the result image have the temp color yet, we must change those to their surrounding most repeated colors.

现在,在损坏的图像中,形状的形式得以保留,边界没有分离,我们将其命名为结果图像。 如果结果图像中的某些像素仍具有临时颜色,则必须将其更改为周围最重复的颜色。

Image for post
Figure 9
图9

the proposed method demonstrates better results compare to the nearest neighbor method in the index image downscaling.

与索引图像缩小中的最近邻方法相比,该方法具有更好的效果。

Image for post
Figure 10
图10

In case of any questions, contact me.

如有任何疑问,请与我联系。

m.amin.ce.sbu@gmail.com

m.amin.ce.sbu@gmail.com

翻译自: https://medium.com/swlh/how-downscale-an-index-image-with-preserving-the-form-of-shapes-92d2bdd059b

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值