Ich wollte auf der Arbeit einige Plots zu einem Avifilm zusammenstellen. Dieser Film sollte eine bestimmte Auflösung haben. Naja, nur leider gibt es für den dazugehörigen Befehl avifile keine Option um explizit eine Größe auszuwählen. Ok, hab ich halt das versteckte figure Fenster auf die gewünschte Größe eingestellt, aber leider wandelt Matlab den Plot dann immer in eine ihm genehme Auflösung um, die viiiel niedriger ist als das was ich wünschte. Irgendwo war ein Hinweis auf die figure-Option PaperPosition, aber die hat auch nix gebracht. Was schon merkwürdig ist, ich will die Plots ja nicht zu Papier bringen.
Nach stundenlangem Suchen und Ausprobieren bin ich dann über eine Mathworks Hilfeseite mit dem tollen Thema "How Do I Generate Higher Resolution AVI Files?" mit der tollen Lösung:
In order to further increase the resolution of your movie, you should maximize the size of the figure window.
Netter Tip, bringt nur nicht viel, wenn die Ausgabegröße nachher eh wieder nur ein Teil von der maximalen Größe ist.
Was mir geholfen hat, das war folgender Code:
Einzelbilder mit der gewünschten Auflösung abspeichern ist was komplizierter, hier muss man die Bildschirmauflöung und die Zielformatauflösung beachten. Ersteres kriegt man mit get(0,'screenpixelsperInch') raus, letzteres ist in Matlab 150dpi (punkte pro Inch), so das man das ganze am besten in Inch ausrechnet. Das bedeutet, man muss die Größe des figure-Fensters über eine Formel anpassen. Allgemein wäre die formel
startgröße = (zielbildgröße/bildauflösung)*bildschirmauflösung
und im Falle von png als Zielbild
startgröße = 150.0*zielbildgröße/get(0,'screenpixelsperInch'))
Als Matlab-Code
English Version
To be short, I haven´t found any solution for this problem in the net. My problem was to exactly size plots so they can be put together to an avi movie with a certain resolution. The only solution on the mathworks site is a near miss. Use the first code above to add plots to an avi file with your desired movie size. These Paper-settings make the output to be of the the same size as the figure size. If you want to output your plot to a PNG file, calculate the necessary figure size with the above function. The only assertion is that you make a PNG with the default pixel density (150dpi per default in Matlab 7.5). Please notice that you can create the figure hidden so it doesn´t flicker on the screen during script execution.
Recent comments