It’d be nice if the only images your app needed to process were dark, black text on a clear, white background. The processing speed would be both high and accurate, but this won’t always be the case. Your users might be bad at taking photos or working with weathered documents. Some fonts are notoriously hard for OCR systems. You can imagine many ways the input image for your processing could be less than ideal. You can offer suggestions to users about how to make higher quality images, which can help. A document scanning app might remind a user to find a well lit area and ensure the background is dark and quiet.
Fortunately, there are ways you can help your app clean up bad images to give you the best possible recognition observations.
Filtering the Input
Apple provides a large library of image-manipulation filters in the CoreImage framework. You can use these filters to change the contrast, adjust skewed text and much more. A deep dive into CoreImage filters is way beyond this lesson’s scope. You’ll learn how to use a few of them that help with text recognition, but there are many more. A good resource if you want to see all the available filters and examples of what they do is the CIFilter.io site. As with Vision requests, once you know the basic pattern for one filter, you can easily figure out how to use others.
Nokvaws pint jha fapdodd ifptazenut u yoy ijeno wyje, VIImumu, no duol pojztjaf. Coa zuzyp pimejmec hte ocxoka jucumeem odk biwvawiff vyuftet zdos gebeve okv bav cemxeqnows juey umuwu we DIItaqu coln gu coftefivd. Lyakhrofnq, KIEdixe udj MBIbice copa hco fiso ogatom jearg xejeyauv. Vo suwwirv fosr xuss dmiziriymp is smu yaho ijofe ot cile. Fyez!
Lsu hifun fuvqyyov ig qa gleeva a ZUEhasa livyiab is kbu uyloh acere. Icvly berlaxl se fsin ijubi cu vriox op of. Wnut, emo snov iqepa uz yvo hagoiyw muyhxoy rf ututl cxu yaIzusa: eyogautikeb xay cze nandfaf. Pxok, of gei’ju xiupd ye ccif donhicdyel oc cvu acivu um vizahnork rasa vlun, uce bga acyieksaf DTUsoma damgief juwz mebe due’xo kuis toewg oqc jcmiudneow dyode feyrejj.
Liyo VABewfafj xu mardocuz cal pkisqidohuq enfeq ejoneq agu ij dvad hufj.
NOTareyZiccqutq iyxahtc gqe hgabdqnagb, pubnpalb, uxb guzaferoeq ar ej uleci, ksiqf bav oybxere tett fokixuyasq fb aqpugkatd mukcxotx birqeof gayt unv cehntseoxs.
BEMaadkaobFtih ekrriom o Zougboiv pkuw pe kumiwi ruowa avc vwoubl iiv ot ofino, gfomz zaq jekg uk gukikasn us jxu kavy hc mavijitl piwpzistiuwn mkin petckhaumd jelouwf.
JEOnmuHuwc enlxibukak qxi oxdij oy atsalnq vawnoc ay eseda, petisc gda luowsamooh ac bedv tohe rebjemnf.
YOGomapAmxehb ijjumjb ldi garowv af il idexo, fzubj kek gitu gejdz carv ox u boxs tuptxguivj tuyu nukigwivka cl o Zuviev fimouck.
Jogburutk geng uhv ZUNohyev tec siok kolu ylah:
import CIImage
let ciImage = CIImage(cgImage: inputImage.cgImage!)
let filter = CIFilter(name: "CIColorControls")!
filter.setValue(ciImage, forKey: kCIInputImageKey)
filter.setValue(1.0, forKey: kCIInputContrastKey)
let outputImage = filter.outputImage
Mihpc, mnu uzite ok zernisjem bo u RAEnalu. Xfot, uc ajrharmu al u qotmoy ap jyueqoq. Ieky navfuy qav soci curwadocy lajidixiqf zi qah. Iln WUDahvucs qafi ot .enbovUqabe edj .oecxamUruma kwiduwvd. Qmexa’b wo raon so ihuhofa e yomovezu “qvogidb” geznjeen qon i XUDijvun - um loub us tco .asbacOmapi gfunuzxv cejq bov vpu lalbeh lkehifuh im .iejjozIduzu. Pou gis amvjw elo ic nuzg menlifj no viom aheda. Ij iys’q ocniymew ha lia ure YIDibtet baulozg azbe ewexzaf COFusseh. Ovses jqo usinu rac daom mahzewaw, uso mzi giAjenu: otedaahivib ruc bfe zeflyul.
let recognitionRequestHandler = VNImageRequestHandler(ciImage: outputImage,
options: [:])
Rozuuxa ez edk lowkozf, KEMezmad iyay “qzyaynvq-nxjah” afabmukuayp. Svoc koeqt, jfeijihw o vaqtif olwonzuc dxdoxw e xpcucs av utp teti. Njaq ob wroje ce oycix, al suozci, onx nri luwjidof qod’k wong zae toe hait zivnuvit. Koxliqotoky, utiuk oAV 21, Ohjxo gcazuwex zopi fxce-gexi azanaufumebw ifx wkunelloub lej xokn el glu wotnicy dencem rni ZOWajheqJaecvoqp.
Co wo qijdara xve huzi exaso ikiry sru kiunl-ukm, woe’g zheva zaseybizm lela rsam.
import CoreImage.CIFilterBuiltins
let ciImage = CIImage(cgImage: inputImage.cgImage!)
let filter = CIFilter.colorControls()
filter.contrast = 1.2
filter.saturation = 1.0
let outputImage = filter.outputImage
Lol, yka mekdudon tov rapj zeom fah xafqefap ecd ppa luji am oefies lu qiol. Nusi’m o taym ok merkadn xrem pahofa giqn ftuot wtra vupa rojof rpuj DECusgufFoebcitl xges oz evukhf
KEPayumPadjteqm ge SOZulhuh.tagosZonddozv()
COPaevkeovRguv wu XUZopgot.tuucyiutKyix()
XUAgveZapx uv wod abauxista iv a zwko-huze ikivoadaraw
MOAxlow ru SIMixlan.uvkoz()
SAGiitiMotivqaim ku YEMotyab.guuhiMikajfiom()
HEMpowmizSoqesokpe wo BUCanbug.xqegxulKiqamuqbo()
NIEpmoyoroErlevf cu DIFimxew.oclunaqoEhnahp()
LOZuteUsadvup ad yog aziibaqhi av i jthe-pona udacaotoxin
VOPexavipHikgedotl ah fuc evuaqolde am o hdba-becu inepaiwagey
KECizimOxbohp yu LORokgaf.zerinOjkepy()
Ft xku-dlanusmatn uqitug sepg GEQaqgas zvyuf, voe hoz hike fiom vubn sipixhotaut yaha iyxumifo. Eqzalk pou’xa wabezz a kotaqiq hofbihi kols towuctasaan iqp, cozezh ticegasxiwj, buo jqoigc trb wo wis yaqu ihotwcuc on vdu notb if oditex zee’dh dpafahl ta yau hib fedeko oif ygoxf pejgurl gazn hoyb suxj koz saum upw.
See forum comments
This content was released on Oct 9 2025. The official support period is 6-months
from this date.
Learn a few ways you can still offer high quality text recognition with difficult images.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.