复制 Photoshop "Multiply effects"
Replicate Photoshop "Multiply effects"
如何使用 Image Magick 库或 iPhone 的 obj-c 代码复制 Photoshop "倍增效果"?我在哪里可以找到一些示例代码?我也看到了这个问题
如果你想要一种简单的方法来做到这一点,我的GPUImage框架有它的GPUImageMultiplyBlendFilter,它接收两个图像,并为每个像素执行红色,绿色,蓝色和alpha通道乘法。它以 GPU 加速的方式执行此操作,因此它可以比在 CPU 上执行相同操作快 4-6 倍。
要使用此功能,请将两个图像设置为混合:
UIImage *inputImage1 = [UIImage imageNamed:@"image1.jpg"];
GPUImagePicture *stillImageSource1 = [[GPUImagePicture alloc] initWithImage:inputImage1];
UIImage *inputImage2 = [UIImage imageNamed:@"image2.jpg"];
GPUImagePicture *stillImageSource2 = [[GPUImagePicture alloc] initWithImage:inputImage2];
然后创建并配置混合过滤器:
GPUImageMultiplyBlendFilter *blendFilter = [[GPUImageMultiplyBlendFilter alloc] init];
[inputImage1 processImage];
[inputImage1 addTarget:blendFilter];
[inputImage2 addTarget:blendFilter];
[inputImage2 processImage];
最后提取混合图像结果:
UIImage *filteredImage = [blendFilter imageFromCurrentlyProcessedOutput];
在当前的实现中,需要注意的是,比iPad 2旧的设备具有有限的纹理大小,因此大于2048x2048的图像目前无法在这些较旧的设备上处理。我正在努力解决这个问题。
Multiply是一种(Adobe称之为)混合模式。混合模式本质上是使用一些数学公式的像素操作。您可以将两个图像混合在一起,也可以使用一个图像,从而产生"自我混合"。
这可以通过逐个像素地对图像进行操作来实现,方法是获取特定像素的每个通道值并对其进行处理。
不幸的是,我对万智牌图书馆并不熟悉。但是,这里有一个公式,给定一个通道值(红色、绿色或蓝色,0 - 255)将返回乘法运算的结果值。
unsigned char result = a * b / 255;
请注意,a 和 b 也必须是无符号字符,否则可能会发生溢出,因为结果将大于一个字节。这是基本的乘法公式,您可以通过分配更大的变量大小并适当修改除数来调整变量以支持每通道 16 位。
重用布拉德·拉尔森的代码对我来说效果很好。
UIImage *inputImage1 = [UIImage imageNamed:@"image1.jpg"];
GPUImagePicture *stillImageSource1 = [[GPUImagePicture alloc] initWithImage:inputImage1];
UIImage *inputImage2 = [UIImage imageNamed:@"sample.jpg"];
GPUImagePicture *stillImageSource2 = [[GPUImagePicture alloc] initWithImage:inputImage2];
GPUImageMultiplyBlendFilter *blendFilter = [[GPUImageMultiplyBlendFilter alloc] init];
[stillImageSource1 processImage];
[stillImageSource1 addTarget:blendFilter];
[stillImageSource2 addTarget:blendFilter];
[stillImageSource2 processImage];
[blendFilter useNextFrameForImageCapture];
UIImage *filteredImage = [blendFilter imageFromCurrentFramebuffer];
[self.imageView setImage:filteredImage];
相关文章:
- 编译时"one or more multiply defined symbols found"错误
- 可点击的QLabel类"multiply defined"函数
- 在构建基本C++程序时"multiply defined symbols found"
- 在安卓中使用 JNI 'multiply'的未定义引用
- 尝试创建流的错误日志 - 获取"one or more multiply defined symbols found"
- 在基本游戏中LNK1169 "one or more multiply defined symbols found"
- 我可以使用 opencv 函数(如 cv::multiply 和 std::vector<cv::Mat> 作为输入和输出参数吗?
- 复制 Photoshop "Multiply effects"
- DirectX 11 Effects
- Side effects in C