1

I have an simple SVG image created with Inkscape.Is there any way to view this SVG image as a figure in MATLAB?or convert the SVG image to any raster format such as JPG,PNG only by using MATLAB?I found exporting a figure to svg. but I want to import svg file as a figure/convert my svg image to any raster form.

Bini
  • 15
  • 1
  • 5
  • related: [Input Vector Graphics into Matlab](http://www.mathworks.com/matlabcentral/answers/58280-input-vector-graphics-into-matlab) – Robert Seifert Sep 11 '14 at 07:26
  • @thewaywewalk yes it is related,I have seen that.but in that I can't find a solution for SVG – Bini Sep 11 '14 at 07:38
  • in [my answer here](http://stackoverflow.com/questions/25229045/exporting-figures-as-vector-graphics-in-pdf-format-using-hg2-update-and-painte/25229055#25229055) you can find a way to open svg-files in inkscape and save them in a different format, directly from matlab. I used it to export figures to svg and convert them afterwards to pdf. You could use the same code to convert your files in advance to png and import them with the known import functions. – Robert Seifert Sep 11 '14 at 08:57
  • @thewaywewalk Thank you,I tried this code filename = 'hello'; inkscapepath = '"my inkscape path"'; system( [inkscapepath ' ' filename ... '.svg --export-area-drawing --export-png=' filename '.png']) It will create hello.png file If I open it wih windows picture viewer it looks fine. same svg image is in png form. But to view it in MATLAB if use imshow('hello.png') a black image with same resolution is coming. the image matrix contains all the entries equal to 0 – Bini Sep 11 '14 at 09:56
  • I think I can't help you on that, I'm not one of the image processing guys. If you happy with the workaround until now, it could be worth asking a new question on this issue with the png file. – Robert Seifert Sep 11 '14 at 10:01
  • I appreciate your help,thank you.I asked a new question on png here. https://stackoverflow.com/questions/25784900/can-not-display-a-png-image-file-which-is-modified-from-a-svg-file-in-matlab – Bini Sep 11 '14 at 10:23

1 Answers1

1

Judging by this answer, this is not possible at the moment. Undocumented Matlab didn't give any results either for possible Java solutions.

The only way is to convert to raster format outside of Matlab (or call the command line from Matlab using system). If you are on a Unix platform, ImageMagick can do that.

Jonathan H
  • 7,591
  • 5
  • 47
  • 80