Antman
Antman

Reputation: 493

How to get title from an image in openCV python

I was wondering how to get a title from a image in OpenCV. At the moment I have this:

#Load a color image in grayscale
img = cv2.imread('lena.jpg',0)

From here, I'd like to get the title from 'img' by doing something like

img.title()

but I don't find any method for doing this. Any suggestion?

Thanks in advance.

Upvotes: 0

Views: 3955

Answers (2)

vasista
vasista

Reputation: 184

There is no direct method in opencv to extract the title from an image. After we load the image in opencv by "imread", the image will be transformed into arrays/matrices. Its all numericals(Christopher Nolan) stuff :P .

One way I can suggest is, you can find "contours" by applying some heuristics like averaging/mean/medium of Area, width, height etc. and also try applying "RLSA(Run Length Smoothing Algorithm)" on those classified contours.

Documention and Code for RLSA is here

Upvotes: 1

GPPK
GPPK

Reputation: 6666

You have set the name of the image, in which case you can store that and refer back to it in the future. There is no way of retriving it from the Mat object as all that stores is the data of the image itself.

instead of:

#Load a color image in grayscale
img = cv2.imread('lena.jpg',0)

save the file name first then use that wherever you need it

image_filename = 'lena.jpg'
img = cv2.imread(image_filename,0)

Upvotes: 1

Related Questions