UIImageEffects:高斯半径大于280时,vImageBoxConvolve_ARGB8888问题出现白色图像? [英] UIImageEffects: white image when Gaussian radius above 280, vImageBoxConvolve_ARGB8888 issue?

查看:188
本文介绍了UIImageEffects:高斯半径大于280时,vImageBoxConvolve_ARGB8888问题出现白色图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apple的 UIImageEffects 示例:

I'm using the Gaussian blur algorithm found in Apple's UIImageEffects example:

CGFloat inputRadius = blurRadius * inputImageScale;
if (inputRadius - 2. < __FLT_EPSILON__)
    inputRadius = 2.;
uint32_t radius = floor((inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5) / 2);

radius |= 1; // force radius to be odd so that the three box-blur methodology works.

NSInteger tempBufferSize = vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, NULL, 0, 0, radius, radius, NULL, kvImageGetTempBufferSize | kvImageEdgeExtend);
void *tempBuffer = malloc(tempBufferSize);

vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, tempBuffer, 0, 0, radius, radius, NULL, kvImageEdgeExtend);
vImageBoxConvolve_ARGB8888(outputBuffer, inputBuffer, tempBuffer, 0, 0, radius, radius, NULL, kvImageEdgeExtend);
vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, tempBuffer, 0, 0, radius, radius, NULL, kvImageEdgeExtend);

free(tempBuffer);

vImage_Buffer *temp = inputBuffer;
inputBuffer = outputBuffer;
outputBuffer = temp;

我还在处理一些较大的图像。不幸的是,当半径超过280时,无论分辨率如何,模糊的图像都会突然变得几乎完全空白。这里发生了什么? vImageBoxConvolve_ARGB8888 是否有未记录的内核宽度/高度限制?还是与根据半径计算框内核宽度的方式有关?

I'm also working with some fairly large images. Unfortunately, when the radius gets over 280, the blurred image suddenly becomes almost completely blank, regardless of the resolution. What's going on here? Does vImageBoxConvolve_ARGB8888 have an undocumented kernel width/height limit? Or does it have to do with the way the box kernel width is computed from the radius?

编辑:

在这里找到了类似的问题: vImageBoxConvolve:内核大小> 255 时出错。高斯半径280大致可转换为260大小的内核,因此该部分匹配。

Found a similar question here: vImageBoxConvolve: errors when kernel size > 255. A Gaussian radius of 280 roughly translates to a 260 size kernel, so that part matches up.

推荐答案

盒子和帐篷可以卷积遇到一个问题,即模值会溢出31位累加器。但是255似乎有点狭窄。至少应有255x255的剩余7位净空。当然,请检查该函数返回的错误代码。如果说一切都很好,那么这似乎是值得的bug。附加一些示例代码,以帮助Apple重现该问题,以确保已解决该问题。

The box and tent convolves can run into a problem where the value modulo overflows the 31-bit accumulator. However 255 seems a bit narrow for that. There should be another 7 bits of headroom at least for 255x255. Certainly, check the error code returned by the function. If it says everything is fine, then this seems bug worthy. Attach some sample code to help Apple reproduce the problem to help ensure it is fixed.

这篇关于UIImageEffects:高斯半径大于280时,vImageBoxConvolve_ARGB8888问题出现白色图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆