gpt4 book ai didi

cocoa - CIColorMap 过滤器错误

转载 作者:行者123 更新时间:2023-12-03 17:44:46 24 4
gpt4 key购买 nike

尝试使用 CIColorMap 过滤器,但应用过滤器时出现运行时错误“[NSImage _feImage]:无法识别的选择器发送到实例 0x100163b10”

在调试器中,我看到 RTE 在执行 applyColorMap 的最后一行(返回)时发生。我知道这两个 (JPG) 文件都存在(imageIn 和在函数中初始化的文件)。那么...知道为什么我会收到此错误吗???

CIColorMap 的文档说: inputGradientImage = 属性类型为 CIAttributeTypeGradient 且显示名称为 Gradient Image 的 CIImage 类。我的问题是因为我没有确定“属性类型”吗?我该怎么做?

我的代码是这样的......在主线上:

    CIImage *myResult = [self applyColorMap: inputCIimage];

那么被调用的函数是:

- (CIImage*) applyColorMap: (CIImage*)imageIn {
// Convert imageIn to B&W by using a gradient image half white / half black
NSString *gradientFP = [[NSString alloc] initWithString:[self myFilepath:
[NSString stringWithString:@"WB-1x20.jpg"]]];
NSImage *colormapImage = [[NSImage alloc] initWithContentsOfFile:gradientFP];
if (colormapImage == nil) {
NSLog (@"Bailing out. Gradient image allocation was NOT successful.");
return nil;
}
CIFilter *colorMapFilter = [CIFilter filterWithName:@"CIColorMap"];
//[colorMapFilter setDefaults];
[colorMapFilter setValue:imageIn forKey:@"inputImage"];
[colorMapFilter setValue:colormapImage forKey:@"inputGradientImage"];
return [colorMapFilter valueForKey:@"outputImage"]; //apply filter and return the new image
}

最佳答案

colormapImage 需要是 CIImage 而不是 NSImage,IIRC。

关于cocoa - CIColorMap 过滤器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3182711/

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