I는 하단 부분의 #if, CICrop 클리핑 및 에지를 검출하기 위해 소벨 실행 단색으로 ciimage 변환있어이 가CIImage (IOS)는 : × 3 회선 추가 단색 필터 든 색
결과 표시하는 데 사용되는 복원 후CIImage *ci = [[CIImage alloc] initWithCGImage:uiImage.CGImage];
CIImage *gray = [CIFilter filterWithName:@"CIColorMonochrome" keysAndValues:
@"inputImage", ci, @"inputColor", [[CIColor alloc] initWithColor:[UIColor whiteColor]],
nil].outputImage;
CGRect rect = [ci extent];
rect.origin = CGPointZero;
CGRect cropRectLeft = CGRectMake(0, 0, rect.size.width * 0.2, rect.size.height);
CIVector *cropRect = [CIVector vectorWithX:rect.origin.x Y:rect.origin.y Z:rect.size.width* 0.2 W:rect.size.height];
CIImage *left = [gray imageByCroppingToRect:cropRectLeft];
CIFilter *cropFilter = [CIFilter filterWithName:@"CICrop"];
[cropFilter setValue:left forKey:@"inputImage"];
[cropFilter setValue:cropRect forKey:@"inputRectangle"];
// The sobel convoloution will produce an image that is 0.5,0.5,0.5,0.5 whereever the image is flat
// On edges the image will contain values that deviate from that based on the strength and
// direction of the edge
const double g = 1.;
const CGFloat weights[] = { 1*g, 0, -1*g,
2*g, 0, -2*g,
1*g, 0, -1*g};
left = [CIFilter filterWithName:@"CIConvolution3X3" keysAndValues:
@"inputImage", cropFilter.outputImage,
@"inputWeights", [CIVector vectorWithValues:weights count:9],
@"inputBias", @0.5,
nil].outputImage;
#define VISUALHELP 1
#if VISUALHELP
CGImageRef imageRefLeft = [gcicontext createCGImage:left fromRect:cropRectLeft];
CGContextDrawImage(context, cropRectLeft, imageRefLeft);
CGImageRelease(imageRefLeft);
#endif
지금 × 3 회선은 ciimage 파이프 이미지 부분의 일부가 될 때마다 I 쇼 최대 회색 에지 검출을 실행 하지만 CIConvolution3X3 접미사가 색 마술 위로 나타나는 처리 파이프 라인 의 부분마다. 이것은 색을 제거하기 위해 CIColorMonochrome 또는 CIPhotoEffectMono 접두사를 사용하는 경우 과 상관없이 발생합니다. 파이프 라인의 맨 아래까지 색상을 유지하는 방법에 대한 아이디어가 있으십니까? TNX
UPD : 놀라 울 등이 하나 개
kernel vec4 gray(sampler image)
{
vec4 s = sample(image, samplerCoord(image));
float r = (s.r * .299 + s.g * .587 + s.b * 0.114) * s.a;
s = vec4(r, r, r, 1);
return s;
}
대신 돌아 오는 색상과 동일한 문제에 사과 결과에서 표준 모노 필터를 사용하는 경우 3 × 3 회선으로 원유 정의 흑백 커널을 실행하지 내 CS 파이프 라인의 일부입니다.
유망 해 보인다. – Bobjt