python高光谱图像显示--坐标轴修改

修改显示的x、y、z轴

成果展示

原来的rgb成像是在上下部位,我看别人的论文显示的都是在左右或者前后部分,也显得比较美观,原来的虽然可以转到,但是不能转360°,所以不能转成把成像部分变到左右位置。
在这里插入图片描述

在这里插入图片描述
第一幅为原来的,第二幅是修改源码之后的。

修改方法

首先找到hypercube.py文件,这里边包括的是转到和显示的代码,里边有draw_cube,具体是下边的这些代码

	    # Top Face (note that the texture's corners have to match the quad's)
        gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[0]))
        gl.glBegin(gl.GL_QUADS)
        gl.glTexCoord2f(0.0, 0.0)
        gl.glVertex3f(hw, -hh, hz)  # Bottom Left Of The Texture and Quad
        gl.glTexCoord2f(1.0, 0.0)
        gl.glVertex3f(hw, hh, hz)  # Bottom Right Of The Texture and Quad
        gl.glTexCoord2f(1.0, 1.0)
        gl.glVertex3f(
            -hw, hh, hz)  # Top Right Of The Texture and Quad
        gl.glTexCoord2f(0.0, 1.0)
        gl.glVertex3f(
            -hw, -hh, hz)  # Top Left Of The Texture and Quad
        gl.glEnd()

        # Far Face
        gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[3]))
        gl.glBegin(gl.GL_QUADS)
        gl.glTexCoord2f(0.0, 0.0)
        gl.glVertex3f(
            -hw, hh, -hz)  # Top Left Of The Texture and Quad
        gl.glTexCoord2f(1.0, 0.0)
        gl.glVertex3f(
            -hw, -hh, -hz)  # Bottom Left Of The Texture and Quad
        gl.glTexCoord2f(1.0, 1.0)
        gl.glVertex3f(
            -hw, -hh, hz)  # Bottom Right Of The Texture and Quad
        gl.glTexCoord2f(0.0, 1.0)
        gl.glVertex3f(
            -hw, hh, hz)  # Top Right Of The Texture and Quad
        gl.glEnd()

        # Near Face
        gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[1]))
        gl.glBegin(gl.GL_QUADS)
        gl.glTexCoord2f(0.0, 0.0)
        gl.glVertex3f(
            hw, -hh, -hz)  # Top Right Of The Texture and Quad
        gl.glTexCoord2f(1.0, 0.0)
        gl.glVertex3f(
            hw, hh, -hz)  # Top Left Of The Texture and Quad
        gl.glTexCoord2f(1.0, 1.0)
        gl.glVertex3f(
            hw, hh, hz)  # Bottom Left Of The Texture and Quad
        gl.glTexCoord2f(0.0, 1.0)
        gl.glVertex3f(
            hw, -hh, hz)  # Bottom Right Of The Texture and Quad
        gl.glEnd()

        # Right face
        gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[2]))
        gl.glBegin(gl.GL_QUADS)
        gl.glTexCoord2f(0.0, 0.0)
        gl.glVertex3f(
            hw, hh, -hz)  # Bottom Right Of The Texture and Quad
        gl.glTexCoord2f(1.0, 0.0)
        gl.glVertex3f(
            -hw, hh, -hz)  # Top Right Of The Texture and Quad
        gl.glTexCoord2f(1.0, 1.0)
        gl.glVertex3f(
            -hw, hh, hz)  # Top Left Of The Texture and Quad
        gl.glTexCoord2f(0.0, 1.0)
        gl.glVertex3f(
            hw, hh, hz)  # Bottom Left Of The Texture and Quad
        gl.glEnd()

        # Left Face
        gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[4]))
        gl.glBegin(gl.GL_QUADS)
        gl.glTexCoord2f(0.0, 0.0)
        gl.glVertex3f(
            -hw, -hh, -hz)  # Bottom Left Of The Texture and Quad
        gl.glTexCoord2f(1.0, 0.0)
        gl.glVertex3f(
            hw, -hh, -hz)  # Bottom Right Of The Texture and Quad
        gl.glTexCoord2f(1.0, 1.0)
        gl.glVertex3f(
            hw, -hh, hz)  # Top Right Of The Texture and Quad
        gl.glTexCoord2f(0.0, 1.0)
        gl.glVertex3f(
            -hw, -hh, hz)  # Top Left Of The Texture and Quad
        gl.glEnd()

        # Bottom Face
        gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[0]))
        gl.glBegin(gl.GL_QUADS)
        gl.glTexCoord2f(0.0, 0.0)
        gl.glVertex3f(
            hw, -hh, -hz)  # Bottom Left Of The Texture and Quad
        gl.glTexCoord2f(1.0, 0.0)
        gl.glVertex3f(
            hw, hh, -hz)  # Bottom Right Of The Texture and Quad
        gl.glTexCoord2f(1.0, 1.0)
        gl.glVertex3f(
            -hw, hh, -hz)  # Top Right Of The Texture and Quad
        gl.glTexCoord2f(0.0, 1.0)
        gl.glVertex3f(
            -hw, -hh, -hz)  # Top Left Of The Texture and Quad
        gl.glEnd()

这个就分为上、下、左、右、前、后六部分,想调对应的位置改一下就行。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值