gpt4 book ai didi

c++ - 图像选择区域拉伸(stretch)为矩形

转载 作者:行者123 更新时间:2023-12-02 10:28:17 25 4
gpt4 key购买 nike

目前正在处理一个问题,如图所示。
problem description
在左侧表示源图像。我有选择区域,可以是 4 个点的多边形。
右侧表示图像切割的结果。可以看出,选择区域中出现的像素被拉伸(stretch)到生成图像的矩形。
我想知道如何通过使用常规 Qt 或 OpenCV 来获得这种效果?

最佳答案

可以使用 Qt 使用以下函数执行该过程:

  • QTransform::squareToQuad : 创建变换矩阵

  • Creates a transformation matrix, trans, that maps a unit square to a four-sided polygon, quad. Returns true if the transformation is constructed or false if such a transformation does not exist.


  • QImage::transformed : 用构造的变换矩阵变换图像

  • Returns a copy of the image that is transformed using the given transformation matrix and transformation mode.


  • QImage::copy :提取所需区域

  • Returns a sub-area of the image as a new image.


    请尝试阅读文档并考虑在可行时发布您的解决方案。

    关于c++ - 图像选择区域拉伸(stretch)为矩形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63361580/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com