From: Jonathon H. <js...@ec...> - 2016-03-09 12:32:44
|
Hi Charlie, The reason that you’re seeing a white image is that the result of applying the SWT is an image in which each pixel value is set to the corresponding stroke width; in a normal FImage valid pixel values are between 0 and 1, however stroke widths will inevitably fall into a much larger range. When you display the image, pixel values outside the 0-1 range will be clipped (hence why you’re seeing a white image). To display the resultant image correctly do the following: StrokeWidthTransform swt = new StrokeWidthTransform(true, new CannyEdgeDetector()); //canny sigma=1; thresholds automatically selected using same algorithm as Matlab implementation swt.processImage(input); DisplayUtilities.display(swt.normaliseImage(input)); The stroke width transform itself doesn’t do text detection - it’s literally an image processing operator that constructs a map of stroke widths at every pixel. The classes to actually find text regions are in the current 1.4-SNAPSHOT versions of OpenIMAJ (in the org.openimaj.image.text.extraction.swt package of the image-feature-extraction dependency). In particular you want to use the SWTTextDetector class (javadoc here: http://openimaj.github.io/openimaj/apidocs/org/openimaj/image/text/extraction/swt/SWTTextDetector.html <http://openimaj.github.io/openimaj/apidocs/org/openimaj/image/text/extraction/swt/SWTTextDetector.html>) There is example code in the sandbox that demonstrates finding letters, words and lines: https://github.com/openimaj/openimaj/blob/master/demos/sandbox/src/main/java/org/openimaj/demos/image/text/extraction/swt/SWTTest.java <https://github.com/openimaj/openimaj/blob/master/demos/sandbox/src/main/java/org/openimaj/demos/image/text/extraction/swt/SWTTest.java> Hope that helps, Jon > On 8 Mar 2016, at 21:07, Charlie Picorini <x.p...@fr...> wrote: > > Dear Team, > > First of all thanks for sharing this java library (with the great tutorials and documentation) with which I'm discovering the world of computer vision! Indeed I'd like to see if there are any noticeable performance (and accuracy) improvements by applying text detection before OCR (the corpus I am using is made of scanned images). > > To practice I am using http://i.stack.imgur.com/EingC.jpg <http://i.stack.imgur.com/EingC.jpg> and I like to apply the Stroke Width Transform algorithm on it but first the image I get now after applying SWT is all white (can't find the right parameter values, although it had worked just beforehand), and then I am lost on how to get the text regions. > > Here is the code I used (inspired from https://sourceforge.net/p/openimaj/discussion/general/thread/a56f1a03/ <https://sourceforge.net/p/openimaj/discussion/general/thread/a56f1a03/>) : > > Main(): > URL u = new URL("http://i.stack.imgur.com/EingC.jpg" <http://i.stack.imgur.com/EingC.jpg>); > FImage grayImage = ImageUtilities.readF( u ).normalise().process( new ResizeProcessor( 620 ) ); > DisplayUtilities.display(grayImage); > applySWTOnImage(grayImage); > > applySWTOnImage(): > > private void applySWTOnImage (FImage input){ > float threshCannyLow = (float)0.1; > StrokeWidthTransform swt = new StrokeWidthTransform(true, threshCannyLow, Math.min(threshCannyLow * 3, 1), (float)0.9); > swt.processImage(input); > DisplayUtilities.display(input); > } > > Regarding the parameters, somewhere in OpenCV documentation was written that the higher threshold in Canny was recommended to be 3 times the lower (can't find it anymore) that's why I set them as such in the constructor. > > As it worked and does not anymore, I could see the result of SWT algorithm a limited number of time, but I am stuck on what to do then to get the text boundaries as shown in the SWT paper (http://yoni.wexlers.org/papers/2010TextDetection.pdf <http://yoni.wexlers.org/papers/2010TextDetection.pdf>) or everywhere when people show their results with SWT. > > So my questions are : why has the result of applying SWT become all white, or as it may be hard to answer, how should the SWT parameters be chosen to get something, and could you give me some hints on the steps to follow after the SWT ? > > Thanks a lot for helping and keep up this great work! > > Regards, > > CP > > ------------------------------------------------------------------------------ > Transform Data into Opportunity. > Accelerate data analysis in your applications with > Intel Data Analytics Acceleration Library. > Click to learn more. > http://makebettercode.com/inteldaal-eval_______________________________________________ > openimaj-discuss mailing list > ope...@li... > https://lists.sourceforge.net/lists/listinfo/openimaj-discuss |