export_fig
==========
A toolbox for exporting figures from MATLAB to standard image and document formats nicely.
### Overview
Exporting a figure from MATLAB the way you want it (hopefully the way it looks on screen), can be a real headache for the unitiated, thanks to all the settings that are required, and also due to some eccentricities (a.k.a. features and bugs) of functions such as `print`. The first goal of export_fig is to make transferring a plot from screen to document, just the way you expect (again, assuming that's as it appears on screen), a doddle.
The second goal is to make the output media suitable for publication, allowing you to publish your results in the full glory that you originally intended. This includes embedding fonts, setting image compression levels (including lossless), anti-aliasing, cropping, setting the colourspace, alpha-blending and getting the right resolution.
Perhaps the best way to demonstrate what export_fig can do is with some examples.
### Examples
**Visual accuracy** - MATLAB's exporting functions, namely `saveas` and `print`, change many visual properties of a figure, such as size, axes limits and ticks, and background colour, in unexpected and unintended ways. Export_fig aims to faithfully reproduce the figure as it appears on screen. For example:
```Matlab
plot(cos(linspace(0, 7, 1000)));
set(gcf, 'Position', [100 100 150 150]);
saveas(gcf, 'test.png');
export_fig test2.png
```
generates the following:
| Figure: | test.png: | test2.png: |
|:-------:|:---------:|:----------:|
|![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275138988274/software/export_fig/fig.png)|![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275139004055/software/export_fig/plot.png)|![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275139029078/software/export_fig/plot2.png)|
Note that the size and background colour of test2.png (the output of export_fig) are the same as those of the on screen figure, in contrast to test.png. Of course, if you want want the figure background to be white (or any other colour) in the exported file then you can set this prior to exporting using:
```Matlab
set(gcf, 'Color', 'w');
```
Notice also that export_fig crops and anti-aliases (smooths, for bitmaps only) the output by default. However, these options can be disabled; see the Tips section below for details.
**Resolution** - by default, export_fig exports bitmaps at screen resolution. However, you may wish to save them at a different resolution. You can do this using either of two options: `-m<val>`, where <val> is a positive real number, magnifies the figure by the factor <val> for export, e.g. `-m2` produces an image double the size (in pixels) of the on screen figure; `-r<val>`, again where <val> is a positive real number, specifies the output bitmap to have <val> pixels per inch, the dimensions of the figure (in inches) being those of the on screen figure. For example, using:
```Matlab
export_fig test.png -m2.5
```
on the figure from the example above generates:
![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275141545505/software/export_fig/plot3.png)
Sometimes you might have a figure with an image in. For example:
```Matlab
imshow(imread('cameraman.tif'))
hold on
plot(0:255, sin(linspace(0, 10, 256))*127+128);
set(gcf, 'Position', [100 100 150 150]);
```
generates this figure:
![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275142174599/software/export_fig/fig2.png)
Here the image is displayed in the figure at resolution lower than its native resolution. However, you might want to export the figure at a resolution such that the image is output at its native (i.e. original) size (in pixels). Ordinarily this would require some non-trivial computation to work out what that resolution should be, but export_fig has an option to do this for you. Using:
```Matlab
export_fig test.png -native
```
produces:
![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275142693372/software/export_fig/camera.png)
with the image being the size (in pixels) of the original image. Note that if you want an image to be a particular size, in pixels, in the output (other than its original size) then you can resize it to this size and use the `-native` option to achieve this.
All resolution options (`-m<val>`, `-q<val>` and `-native`) correctly set the resolution information in PNG and TIFF files, as if the image were the dimensions of the on screen figure.
**Shrinking dots & dashes** - when exporting figures with dashed or dotted lines using either the ZBuffer or OpenGL (default for bitmaps) renderers, the dots and dashes can appear much shorter, even non-existent, in the output file, especially if the lines are thick and/or the resolution is high. For example:
```Matlab
plot(sin(linspace(0, 10, 1000)), 'b:', 'LineWidth', 4);
hold on
plot(cos(linspace(0, 7, 1000)), 'r--', 'LineWidth', 3);
grid on
export_fig test.png
```
generates:
![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275067898764/software/export_fig/test.png)
This problem can be overcome by using the painters renderer. For example:
```Matlab
export_fig test.png -painters
```
used on the same figure generates:
![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275067997573/software/export_fig/test2.png)
Note that not only are the plot lines correct, but the grid lines are too.
**Transparency** - sometimes you might want a figure and axes' backgrounds to be transparent, so that you can see through them to a document (for example a presentation slide, with coloured or textured background) that the exported figure is placed in. To achieve this, first (optionally) set the axes' colour to 'none' prior to exporting, using:
```Matlab
set(gca, 'Color', 'none'); % Sets axes background
```
then use export_fig's `-transparent` option when exporting:
```Matlab
export_fig test.png -transparent
```
This will make the background transparent in PDF, EPS and PNG outputs. You can additionally save fully alpha-blended semi-transparent patch objects to the PNG format. For example:
```Matlab
logo;
alpha(0.5);
```
generates a figure like this:
![](https://sites.google.com/site/oliverwoodford/_/rsrc/1321287050167/software/export_fig/logo.png.jpg)
If you then export this to PNG using the `-transparent` option` `you can then put the resulting image into, for example, a presentation slide with fancy, textured background, like so:
![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275128181107/software/export_fig/overlay.png?height=375&width=400)
and the image blends seamlessly with the background.
**Image quality** - when publishing images of your results, you want them to look as good as possible. By default, when outputting to lossy file formats (PDF, EPS and JPEG), export_fig uses a high quality setting, i.e. low compression, for images, so little information is lost. This is in contrast to MATLAB's print and saveas functions, whose default quality settings are poor. For example:
```Matlab
A = im2double(imread('peppers.png'));
B = randn(ceil(size(A, 1)/6), ceil(size(A, 2)/6), 3) * 0.1;
B = cat(3, kron(B(:,:,1), ones(6)), kron(B(:,:,2), ones(6)), kron(B(:,:,3), ones(6)));
B = A + B(1:size(A, 1),1:size(A, 2),:);
imshow(B);
print -dpdf test.pdf
```
generates a PDF file, a sub-window of which looks (when zoomed in) like this:
![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275124307835/software/export_fig/peppers_bad.png)
while the command
```Matlab
export_fig test.pdf
```
on the same figure produces this:
![](https://sites.google.com/site/oliverwoodford/_/rsrc/1275124443133/software/export_fig/peppers_good.png)
While much better, the image still contains some compression artifacts (see the low level noise around the edge of the pepper). You may prefer to export with no artifacts at all, i.e. lossless compression. Alternatively, you might need a smaller file, and be willing to accept more compression. Either
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields ∗ 源代码 open pose 实时人体姿态估计 caffe+python+matlab
资源推荐
资源详情
资源评论
收起资源包目录
Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields ∗ 源代码 (107个子文件)
config 772B
entries 2KB
entries 2KB
pose.gif 2.75MB
dance.gif 1.99MB
shake.gif 1.95MB
.gitignore 31B
.gitignore 18B
.gitmodules 0B
plot_log.gnuplot 2KB
demo-checkpoint.ipynb 10.47MB
demo.ipynb 5.65MB
upper.jpg 631KB
ski.jpg 299KB
upper2.jpg 227KB
LICENSE 9KB
LICENSE 1KB
export_fig.m 30KB
loadjson.m 18KB
savejson.m 18KB
applyModel.m 16KB
saveubjson.m 16KB
loadubjson.m 15KB
connect56LineVec.m 13KB
connect43LineVec.m 12KB
genJSON.m 10KB
print2eps.m 9KB
im2gif.m 7KB
demo_ubjson_basic.m 6KB
print2array.m 6KB
demo_jsonlab_basic.m 6KB
fix_lines.m 6KB
ghostscript.m 5KB
eps2pdf.m 5KB
genCOCOMask.m 4KB
isolate_axes.m 4KB
pdftops.m 3KB
evalMPII.m 3KB
evalCOCO.m 3KB
config.m 3KB
mat2im.m 3KB
user_string.m 2KB
append_pdfs.m 2KB
tight_subplot.m 2KB
getANNO.m 2KB
pdf2eps.m 1KB
varargin2struct.m 1KB
jsonlab_selftest.m 995B
jsonopt.m 906B
copyfig.m 846B
mergestruct.m 796B
demo.m 708B
jsonlab_speedtest.m 675B
using_hg2.m 376B
jsonlab_basictest.matlab 10KB
jsonlab_selftest.matlab 4KB
README.md 22KB
README.md 5KB
arch.png 952KB
Loss_l2.png 8KB
Loss_l1.png 7KB
pose_train_test.prototxt 50KB
pose_deploy.prototxt 45KB
pose_deploy.prototxt 45KB
pose_solver.prototxt 809B
setLayers.py 24KB
genLMDB.py 7KB
util.py 3KB
config_reader.py 1KB
plotLoss.sh 1KB
getData.sh 929B
get_model.sh 262B
get_lmdb.sh 256B
train_pose.sh 185B
LICENSE_GPLv3.txt.svn-base 35KB
README.txt.svn-base 19KB
loadjson.m.svn-base 18KB
savejson.m.svn-base 17KB
saveubjson.m.svn-base 16KB
loadubjson.m.svn-base 15KB
jsonlab_basictest.matlab.svn-base 10KB
demo_ubjson_basic.m.svn-base 6KB
demo_jsonlab_basic.m.svn-base 6KB
jsonlab_selftest.matlab.svn-base 4KB
ChangeLog.txt.svn-base 4KB
AUTHORS.txt.svn-base 2KB
LICENSE_BSD.txt.svn-base 2KB
varargin2struct.m.svn-base 1KB
jsonlab_selftest.m.svn-base 995B
jsonopt.m.svn-base 906B
mergestruct.m.svn-base 796B
jsonlab_speedtest.m.svn-base 675B
example2.json.svn-base 583B
example4.json.svn-base 500B
example1.json.svn-base 436B
example3.json.svn-base 256B
saveubjson.m.svn-base 29B
loadjson.m.svn-base 29B
savejson.m.svn-base 29B
loadubjson.m.svn-base 29B
共 107 条
- 1
- 2
资源评论
林小轶
- 粉丝: 57
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功