可能重复:
OCR using openCV
我想将灰色图像转换为黑白图像(具有良好的对比度)。我正在使用openCV。我在过去3天里一直在努力,但我的输出图像并不清楚如下所示。
由于
原始图片:
输出图片:
答案 0 :(得分:0)
试试这个会帮助你获得正确的图像
UIImage *image=[UIImage imageNamed:@"EUqAd.jpg"];
UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 280, 150)];
imageView.image=image;
[self.view addSubview:imageView];
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClipToMask(context, rect, image.CGImage);
CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImage *flippedImage = [UIImage imageWithCGImage:img.CGImage
scale:1.0 orientation: UIImageOrientationDownMirrored];
UIImageView *imageView1=[[UIImageView alloc]initWithFrame:CGRectMake(20, 200, 280, 150)];
imageView1.image=flippedImage;
[self.view addSubview:imageView1];