Ask Your Question

How can we distinguish raster and vector images?

asked 2020-02-26 05:18:04 -0600

I have to differentiate raster and vector images without its file extension

edit retag flag offensive close merge delete



off-topic, imho

berak gravatar imageberak ( 2020-02-26 06:12:48 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2020-03-23 18:54:48 -0600

If you're talking about file formats, it's off-topic because it has nothing to do with OpenCV specifically.

Make a list of known raster format headers (eg. PNG files begin with \x89PNG\r\n\x1a\n) and a list of known vector format headers (eg. SVG is XML with an svg root element... it may or may not have and <?xml ...> declaration at the top) and check whether the file matches them.

The imread function doesn't support loading vector file formats.

If you're talking about distinguishing photographic/scanned/etc. content from losslessly-compressed (eg. PNG) files rendered from vector images (eg. inkscape --export-png=FILENAME.png FILENAME.svg) then that would be an appropriate OpenCV question.

(And one that would prompt answers I'd be curious about. I'm a novice in this field, so my only intuition would be to explore approaches based on checking how noisy the image is.)

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2020-02-26 04:21:39 -0600

Seen: 304 times

Last updated: Feb 26 '20