English 中文(简体)
• 基本食品标准
原标题:Binary quantize a CGImage (is image majorly bright or dark)

我有一次智囊团,我想确定它是否非常光明,还是非常黑暗。 我肯定能够简单地通过矩阵进行循环,看看足够数量的六分母是否超过了预期的门槛值。 然而,由于我是新的图像处理机构,我认为必须在核心学科或高科技领域建立功能,这些功能更合适,甚至可能加快。

最佳回答

核心学科(aka Quartz 2D)在这方面没有任何职能。 宏观顾问的核心 X有CIAreaAverageCIAreaHistogram,这可能有助于你,但我不认为SOS(5.0.1)。

本组织确实有《加速框架:<<功能和相关功能可能有助于您。

问题回答

这里,如何使用CIAverage in anOS:

    CGRect inputExtent = [self.inputImage extent];
    CIVector *extent = [CIVector vectorWithX:inputExtent.origin.x
                                           Y:inputExtent.origin.y
                                           Z:inputExtent.size.width
                                           W:inputExtent.size.height];
    CIImage* inputAverage = [CIFilter filterWithName:@"CIAreaAverage" keysAndValues:@"inputImage", self.inputImage, @"inputExtent", extent, nil].outputImage;

    //CIImage* inputAverage = [self.inputImage imageByApplyingFilter:@"CIAreaMinimum" withInputParameters:@{@"inputImage" : inputImage, @"inputExtent" : extent}];
    EAGLContext *myEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
    NSDictionary *options = @{ kCIContextWorkingColorSpace : [NSNull null] };
    CIContext *myContext = [CIContext contextWithEAGLContext:myEAGLContext options:options];

    size_t rowBytes = 32 ; // ARGB has 4 components
    uint8_t byteBuffer[rowBytes]; // Buffer to render into

    [myContext render:inputAverage toBitmap:byteBuffer rowBytes:rowBytes bounds:[inputAverage extent] format:kCIFormatRGBA8 colorSpace:nil];

    const uint8_t* pixel = &byteBuffer[0];
    float red   = pixel[0] / 255.0;
    float green = pixel[1] / 255.0;
    float blue  = pixel[2] / 255.0;
    NSLog(@"%f, %f, %f
", red, green, blue);


    return outputImage;
}

@end

衡量这一具体指标的方法比测量强度要快、更加有效,事实上,如果你打算与它做的是测量。

图像钥匙是另一个;它是由密度的总和确定的,但并不需要加以重复。 图像关键公式(如果需要的话,我有这种公式)所回升的价值可用于采用简单的伽马调整进行当地适应性地貌测绘(你想要做些什么)。

这并非是困难的,而且很明显,你有技能,有经验以更快、更有效的方式在轻度和黑暗的形象之间进行区分。

更有甚者,你应当建立一种模式和做法,在你能够的地方使用图像测量公式而不是其图。 它们旨在解释信息,而不仅仅是收集信息。 不仅如此,而且常常是互操作的,这意味着它们可以被打上另一个顶头,就像核心图像过滤器一样。

具体内容如下:

Gamma 适应图像钥匙,载于劳伦斯·梅伊兰为高动态图像绘制图第14页。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签