2

Building a system which search for a specific region in the picture, and saves it. Everything works fine. Mostly I am going to extract these regions from pdf books.

So I am looking for a solution to treat PDF file in matlab as an array of images (each page is an image). Up till now the only thing I have found is how to open pdf files in matlab.

The best solution I came up with is to export PDF as many PNG images and iterate through them. There is nothing bad with these idea, but I am wondering am I missing something

Salvador Dali
  • 214,103
  • 147
  • 703
  • 753

2 Answers2

0

Judging from this page it appears to be impossible to import pdf directly into matlab:

And a quick file exchange search for 'pdf import' only offers an attempt to extract text, rather than the images.

So all in all your approach of saving the pdf as images and then importing them seems to be the way to go.

Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122
0

I agree with Salvador Dali and Dennis. To convert each page of the PDF to a png image, I downloaded imagemagick and followed the commands here:

https://aleksandarjakovljevic.com/convert-pdf-images-using-imagemagick/ Specifically: convert -density 150 -antialias "input_file_name.pdf" -resize 1024x -quality 100 "output_file_name-%03d.png"

Of course, there are other discussion about using ImageMagick for this purpose: Converting a PDF to PNG and Convert PDF to PNG using ImageMagick

This is an old thread, but it's the one I found when I asked the same question, so I thought I would elaborate in case it's helpful to future users who also land on this thread.

LSlaug
  • 1
  • 1
  • Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. – baduker Mar 30 '18 at 08:00