I tried extracting articles from the newspaper image, but headings are being separated with rlsa algorithm horizontal and vertical of some pixel value in the first image. If I tried with more pixel value, articles are merging which is showed in second image. Can anyone suggest the best method to separate articles from the image in python and opencv?
for i in range(1,a):
c = 1
for j in range(1, b):
if im_bw[i, j] == 0:
if (j-c) <= 10:
im_bw[i, c:j] = 0
c = j
if (b - c) <= 10:
im_bw[i, c:b] = 0
for i in range(1, b):
c = 1
for j in range(1, a):
if im_bw[j, i] == 0:
if (j-c) <= 9:
im_bw[c:j, i] = 0
c = j
if (b - c) <= 9:
im_bw[c:b, i] = 0
a is number of rows b is number of columns of an binary image
How algorithm worked on binary image and red mark shows the merging of articles
I have an approach worked for most of the images.
Removing lines helps because some e-papers keeps lines as article separator. We can achieve better results with more processing of the images. Heuristics like average width, average height, average area can be implemented on the contours left on the image after applying above steps to achieve better results.
Coming to the above question, the articles always with the white background. Without white background are clearly "Ads" or "pictures" or "miscellaneous" stuff. Removing pictures from the above 4 mentioned steps clears solves this issue.
PS: Choosing a value for RLSA horizontal and vertical is always mystery. Since the gap of the article varies from edition to edition.
Edit:
the above problem is basically applying Heuristics. Read through this
https://medium.com/@vasista/extract-title-from-the-image-documents-in-python-application-of-rlsa-58f91237901f
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With