gpt4 book ai didi

ios - 如何正确使用 CIWarpKernel 坐标系?

转载 作者:行者123 更新时间:2023-11-29 12:07:42 26 4
gpt4 key购买 nike

我正在尝试在 ios 中构建自定义 warp 内核。

我有这个内核代码

var kernelCode =
" kernel vec2 partialFlip(vec2 center, float width, float height) { " + "\n" +
" vec2 p = destCoord(); " + "\n" +
" float x = width - p.x; " + "\n" +
" float y = height - p.y; " + "\n" +
" return vec2(x, y); } ";

kernel = CIWarpKernel(string: kernelCode);

我想在用户点击图像时垂直和水平翻转一个区域。该区域是在用户点击和恒定宽度的帮助下计算的。就在我点击图像时,整个图像变成了一种颜色,我假设每个像素都从一个像素中获取它的新颜色,为了使用我调用的内核

 var width = radius;
var height = radius;
var roi = CGRectMake(center.X - width / 2,center.Y - height / 2, width, height);
return kernel.applyWithExtent(roi, roiCallback: {(n : Int32, rect: CGRect) -> CGRect in return rect; }, inputImage: image, arguments: [center, width, height])!;

我的中心和半径来自图像坐标系。 我在这里错过了什么吗?我应该将所有内容缩小到 [0,1] 吗?

最佳答案

Core Image 坐标以非标准化像素为单位。坐标是笛卡尔坐标(即原点在左下角)

关于ios - 如何正确使用 CIWarpKernel 坐标系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34454272/

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