平衡二叉树之路径压缩

思路:将当前查询结点的路径上的所有结点的父亲都指向根结点
步骤
①按原先写法获得x的根结点r
②重新从x开始走一遍寻找根结点的过程,把路径上经过的所有结点的父亲全部改为根结点r
代码

int findFather(intx)
{
	int a=x;
	while(x!=father[x])
	{
		x=fater[x];
	}
	//x此时存放的是根结点,下面把路径上的所有结点的father都改成根结点
	while(a!=father[a])
	{
		int z=a;//因为a要被father[a]覆盖,所以先保存a的值,以修改father[a]
		a=father[a];//a回溯父亲节点
		father[z]=x;//将原先的节点a的父亲节点改为根结点x;
	}
	return x;返回根结点;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
文章作者写的matlab源代码,该文章发表在Digital Signal Processing: Ke-Kun Huang , Hui Liu, Chuan-Xian Ren, Yu-Feng Yu and Zhao-Rong Lai. Remote sensing image compression based on binary tree and optimized truncation. Digital Signal Processing, vol. 64, pp. 96-106, 2017. (http://dx.doi.org/10.1016/j.dsp.2017.02.008) 遥感图像数据非常广泛,因此需要通过空间设备上的低复杂度算法进行压缩。具有自适应扫描顺序(BTCA)的二叉树编码是一个的有效算法。然而,对于大规模遥感图像,BTCA需要大量的内存,而且不能随机存取。在本文中,我们提出了一种基于BTCA的新的编码方法。小波图像首先划分为几个块,并由BTCA单独编码的。根据BTCA的属性,仔细选择每个块的有效截断点,以优化速率失真的比例,从而获得更高的压缩比、更低的内存要求和随机访问性能。由于没有任何熵编码,所提出的方法简单快速,非常适合于空间设备。对三个遥感图像集进行实验,结果表明它可以显着提高PSNR、SSIM和VIF,以及主观视觉体验。 The remote sensing image data is so vast that it requires compression by low-complexity algorithm on space-borne equipment. Binary tree coding with adaptive scanning order (BTCA) is an effective algorithm for the mission. However, for large-scale remote sensing images, BTCA requires a lot of memory, and does not provide random access property. In this paper, we propose a new coding method based on BTCA and optimize truncation. The wavelet image is first divided into several blocks which are encoded individually by BTCA. According the property of BTCA, we select the valid truncation points for each block carefully to optimize the ratio of rate-distortion, so that a higher compression ratio, lower memory requirement and random access property are attained. Without any entropy coding, the proposed method is simple and fast, which is very suitable for space-borne equipment. Experiments are conducted on three remote sensing image sets, and the results show that it can significantly improve PSNR, SSIM and VIF, as well as subjective visual experience.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值