Daniel, my experience is that using multiple (test ? cond1 : cond2) constructs often give unexpected results.
If you commenting out three of the four the function suddenly works. maybe you can avoid this construct. Just my two cents. best, Achim Breidenbach Boinx Software Ltd. On 13.03.2014, at 20:56, Daniel Holtmann-Rice <[email protected]> wrote: > Hi, > > I’ve recently discovered QC and have started using it for image processing. I > work a lot with floating point images, and needed a node that calculates the > global min value over an image. Unfortunately CIAreaMinimum doesn’t work for > floating point images with values outside [0, 1] (also a bug?), so I thought > I’d throw together a simple reduce operation using the Core Image Filter > node. The basic idea is to make the destination image half the size of input > image, and calculate the min in 2x2 patches. By doing this repeatedly, the > input image is reduced to a 1x1 image containing the minimum. > > I pasted the kernel/filter functions I’ve tried below, but it looks like I’ve > run into a strange bug. Any values outside the lower left corner become > transparent. This is despite the fact that most of the samples are within the > bounds of the image (except for a possibly one pixel strip on the top and > right). Furthermore, everything looks fine if I just return val1 (or 2 or 3 > or 4) below, but if I return an average of them things fail again. > > I’ve attached a minimal QC project demonstrating the issue. Anyone have any > idea what might be going on? > > The kernel: > > kernel vec4 min2x2(sampler image) > { > vec2 pos = destCoord(); > vec4 val1 = sample(image, samplerTransform(image, 2.0*pos + vec2(0, > 0))); > vec4 val2 = sample(image, samplerTransform(image, 2.0*pos + vec2(1, > 0))); > vec4 val3 = sample(image, samplerTransform(image, 2.0*pos + vec2(0, > 1))); > vec4 val4 = sample(image, samplerTransform(image, 2.0*pos + vec2(1, > 1))); > vec4 ret = vec4(1e38); > ret = val1.a > 0.1 ? min(ret, val1) : ret; > ret = val2.a > 0.1 ? min(ret, val2) : ret; > ret = val3.a > 0.1 ? min(ret, val3) : ret; > ret = val4.a > 0.1 ? min(ret, val4) : ret; > ret.a *= float(ret.a < 1e38); > return ret; // What I want to do > // return val1; // Ok!!! > // return (val1 + val2) / 2.0; // Not ok… ??? > } > > > For the filter function: > > function __image main(__image image) { > var extent = image.extent; > // Would like to make this extent.width > 1 || extent.height > 1 > while (extent.width > 256 || extent.height > 256) { > extent.width = Math.ceil(extent.width / 2); > extent.height = Math.ceil(extent.height / 2); > image = min2x2.apply(extent, null, image); > } > return image; > } > > <Min.qtz> _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Quartzcomposer-dev mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/quartzcomposer-dev/achim%40boinx.com > > This email sent to [email protected] _______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com This email sent to [email protected]

