首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >基于CoreImage / GPUImage的水准测量与匹配曝光

基于CoreImage / GPUImage的水准测量与匹配曝光
EN

Stack Overflow用户
提问于 2016-07-15 13:17:32
回答 1查看 128关注 0票数 0

我想知道是否有可能使用CoreImageGPUImage对一组图像进行曝光。我该怎么做呢?

示例:假设您有4幅图像,但第三幅的曝光情况不同。你怎样才能使曝光达到水平,使所有4幅图像都有相同的曝光量呢?

我的一个想法是使用AVCapture测量和匹配曝光,即如果输入图像为- 2.0,那么只需使用CoreImage添加2.0即可。

另一个想法是实现直方图均衡。

以前有人处理过同样的任务吗?有什么见解吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-28 00:08:35

您可以使用CoreImage (#import )和ImageIO (CGImage)提取带有EXIF字典键键的exif元数据:kCGImagePropertyExifExposureTime、kCGImagePropertyExifExposureMode、kCGImagePropertyExifExposureProgram、kCGImagePropertyExifExposureBiasValue、kCGImagePropertyExifExposureIndex、kCGImagePropertyExifWhiteBalance

代码语言:javascript
运行
复制
- (NSDictionary*) exifData: (NSString*) path {  

NSDictionary* dic   =   nil;
NSURL* url          =   [NSURL fileURLWithPath: path];  

if ( url )  
{
    CGImageSourceRef source = CGImageSourceCreateWithURL ((CFURLRef) url, NULL);

    if (source != nil)
    {
        CFDictionaryRef metadataRef = 
        CGImageSourceCopyPropertiesAtIndex (source, 0, NULL);  
        if (metadataRef)   
        {  
            NSDictionary* immutableMetadata = (NSDictionary *)metadataRef;  
            if (immutableMetadata)
            {
                dic = [NSDictionary dictionaryWithDictionary : (NSDictionary *)metadataRef];
            }
            CFRelease ( metadataRef );
        }
        CFRelease(source);  
        source = nil;  
     }
 }

return dic;
}

用法:

代码语言:javascript
运行
复制
NSDictionary* dic = [self exifData: path];  
if (dic)
{  
    NSString *s = [dic valueForKey: kCGImagePropertyExifExposureTime];  
    NSLog(@"Image : %@ - ExposureTime : %.2f", path, [s floatValue]);  
}

然后用以下方法改变曝光或白平衡:

代码语言:javascript
运行
复制
- (UIImage *) changeImageExposure:(NSString*) imagename exposure:(float) exposure {  
   CIImage *inputImage = [[CIImage alloc] initWithImage:[UIImage imageNamed: imagename]];
   CIFilter *exposureAdjustmentFilter = [CIFilter filterWithName:@"CIExposureAdjust"];
   [exposureAdjustmentFilter setValue:inputImage forKey:kCIInputImageKey];
   [exposureAdjustmentFilter setValue:[NSNumber numberWithFloat:exposure] forKey:@"inputEV"];
   CIImage *outputImage = exposureAdjustmentFilter.outputImage;
   CIContext *context = [CIContext contextWithOptions:nil];
   return [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38397154

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档