From: Tim Hunter Date: 2008-09-02T23:59:48+09:00 Subject: Re: finding blocks in black-and-white images (efficiently) Axel Etzold wrote: > Dear all, > > I have a number of black-and-white scanned pages. To prepare them for OCR, > I have to split them in columns and rows. Additionally, somewhere in between, there > are pictures, which also need to be separated. > > So, in a page that might look like this: > > Text1 Text4 Text6 > > Text2 Pict1 Text7 > > Text3 Text5 Pict2 > > I'd like to find the largest blocks of white which separate the texts and pictures, both horizontally > and vertically. > > Right now, I would use RMagick with export_pixels_to_str and then regular expressions to find the > zeros, but I am not sure whether there's a more effective way for this purpose.... > > Do you have any suggestions ? > > Thank you very much, > > Best regards, > > Axel > > I took the liberty of posting your question to the ImageMagick forum [http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=11980]. There's some pretty good IM users on that forum and usually it's not hard to convert IM commands and options to RMagick code. If they have any suggestions I'll let you know. -- RMagick: http://rmagick.rubyforge.org/