当与 C 数据库链接时的完全图像支持
扩展的 LibraryLink 支持直接向外部程序库发送或接受 Image 对象.
以下是从以一个32位实数数据类型表示的图像中创建棕褐色(sepia)效果的范例. 由此参见完整范例.
static void isepia(raw_t_real32 *out, raw_t_real32 *in, mint width,
mint height, mint channels) {
for (mint ii = 0; ii < height; ii++) {
for (mint jj = 0; jj < width; jj++) {
for (mint kk = 0; kk < channels; kk++) {
mint index = channels * (ii * width + jj);
raw_t_real32 r = in[index + 0];
...
out[index + 0] = r * static_cast<raw_t_real32>(0.393) +
g * static_cast<raw_t_real32>(0.769) +
b * static_cast<raw_t_real32>(0.189);
...
for (int ii = 3; ii < channels; ii++) {
out[index + ii] = in[index + ii];
}
}
}
}
return;
}
EXTERN_C DLLEXPORT int speia(WolframLibraryData libData, mint Argc,
MArgument *Args, MArgument res) {
...
data_in = imgFuns->MImage_getReal32Data(image_in);
data_out = imgFuns->MImage_getReal32Data(image_out);
...
ispeia(data_out, data_in, width, height, channels);
MArgument_setMImage(res, image_out);
return LIBRARY_NO_ERROR;
}
从程序库载入函数.
Out[1]= | |
将加载函数应用与任意图像.
Out[2]= | |