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://farm6.staticflickr.com/5616/15589249291_16e485c29a_o_d.png)|![](https://farm4.staticflickr.com/3944/15406302850_4d2e1c7afa_o_d.png)|![](https://farm6.staticflickr.com/5607/15568225476_8ce9bd5f6b_o_d.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 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://farm4.staticflickr.com/3937/15591910915_dc7040c477_o_d.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://farm4.staticflickr.com/3942/15589249581_ff87a56a3f_o_d.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://farm6.staticflickr.com/5604/15589249591_da2b2652e4_o_d.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://farm4.staticflickr.com/3956/15592747732_f943d4aa0a_o_d.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://farm4.staticflickr.com/3945/14971168504_77692f11f5_o_d.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://farm4.staticflickr.com/3933/15405290339_b08de33528_o_d.png)
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://farm6.staticflickr.com/5599/15406302920_59beaefff1_o_d.png)
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://farm6.staticflickr.com/5613/15405290309_881b2774d6_o_d.png)
while the command
```Matlab
export_fig test.pdf
```
on the same figure produces this:
![](https://farm4.staticflickr.com/3947/14971168174_687473133f_o_d.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 way, export_fig has an option that can suit your needs: `-q<val>`, where <val> is a number from 0-100, will set the level of lossy image compression (again in PDF, EPS and JPEG outputs only; other formats are lossless), from high compression (0) to low compression/high quality (100). If you want lossless compression in any of those formats then specify a <val> greater than 100. For examp
没有合适的资源?快使用搜索试试~ 我知道了~
增强拉格朗日数字图像相关和跟踪研究(Matlab代码实现).zip
共230个文件
m:122个
png:43个
jpg:33个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 174 浏览量
2023-04-22
10:40:07
上传
评论
收藏 85.07MB ZIP 举报
温馨提示
1.版本:matlab2014/2019a,内含运行结果,不会运行可私信 2.领域:智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,更多内容可点击博主头像 3.内容:标题所示,对于介绍可点击主页搜索博客 4.适合人群:本科,硕士等教研学习使用 5.博客介绍:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可si信
资源推荐
资源详情
资源评论
收起资源包目录
增强拉格朗日数字图像相关和跟踪研究(Matlab代码实现).zip (230个子文件)
ImageSelection.class 1KB
ba_interp2.cpp 11KB
export_fig_LICENSE 1KB
Demo3.gif 1.59MB
Example_aldic_foam_compression_strain_eyy.gif 1.3MB
Demo2.gif 807KB
Demo1.gif 323KB
ImageSelection.java 1KB
img_0570_WS20_ST10_strain_maxshear.jpg 283KB
img_0570_WS20_ST10_strain_vonMises.jpg 275KB
img_0570_WS20_ST10_strain_principal_max.jpg 274KB
img_0570_WS20_ST10_strain_exx.jpg 270KB
img_0570_WS20_ST10_strain_exy.jpg 269KB
img_0570_WS20_ST10_strain_principal_min.jpg 269KB
img_0570_WS20_ST10_strain_eyy.jpg 267KB
img_0570_WS20_ST10_DispV.jpg 264KB
img_0570_WS20_ST10_DispU.jpg 260KB
oht_cfrp_11_WS40_ST32_strain_maxshear.jpg 243KB
oht_cfrp_11_WS40_ST32_strain_vonMises.jpg 242KB
oht_cfrp_11_WS40_ST32_strain_eyy.jpg 240KB
oht_cfrp_11_WS40_ST32_strain_principal_max.jpg 239KB
oht_cfrp_11_WS40_ST32_strain_exy.jpg 239KB
oht_cfrp_11_WS40_ST32_strain_principal_min.jpg 239KB
oht_cfrp_11_WS40_ST32_strain_exx.jpg 238KB
oht_cfrp_11_WS40_ST32_DispU.jpg 238KB
oht_cfrp_11_WS40_ST32_DispV.jpg 235KB
oht_cfrp_11_WS32_ST16_strain_exx.jpg 227KB
oht_cfrp_11_WS32_ST16_strain_vonMises.jpg 226KB
oht_cfrp_11_WS32_ST16_strain_principal_min.jpg 223KB
oht_cfrp_11_WS32_ST16_strain_principal_max.jpg 223KB
oht_cfrp_11_WS32_ST16_strain_maxshear.jpg 223KB
oht_cfrp_11_WS32_ST16_strain_eyy.jpg 223KB
oht_cfrp_11_WS32_ST16_strain_exy.jpg 222KB
oht_cfrp_11_WS32_ST16_DispU.jpg 219KB
oht_cfrp_11_WS32_ST16_DispV.jpg 216KB
img_0570 _WS20_ST10_maxshear.jpg 190KB
img_0570 _WS20_ST10_exy.jpg 188KB
img_0570 _WS20_ST10_exx.jpg 187KB
img_0570 _WS20_ST10_eyy.jpg 187KB
img_0570 _WS20_ST10_DispV.jpg 183KB
img_0570 _WS20_ST10_DispU.jpg 183KB
LICENSE 1KB
export_fig.m 54KB
funRemoveOutliersQuadtree.m 52KB
regularizeNd.m 43KB
main_ALDIC.m 40KB
main_ALDIC_QuadtreeHole.m 34KB
main_ALDIC_Quadtree.m 34KB
gridfit.m 34KB
Subpb2Quadtree.m 21KB
funIntegerSearchMg.m 20KB
funRemoveOutliers.m 20KB
funICGN_Subpb1.m 20KB
print2eps.m 20KB
Plotstress.m 19KB
funGlobalNodalStrainQuadtree.m 18KB
PlotstressQuadtree.m 18KB
inpaint_nans.m 16KB
Plotstrain.m 16KB
funICGN.m 16KB
Plotstress0Quadtree.m 15KB
Plotstress0.m 14KB
PlotstrainQuadtree.m 14KB
funDerivativeOp.m 14KB
Subpb1Quadtree.m 12KB
Plotstrain0.m 11KB
Subpb1.m 11KB
Plotstrain0Quadtree.m 11KB
LocalICGN.m 10KB
funIntegerSearch.m 10KB
Subpb2.m 10KB
print2array.m 9KB
funParaInput.m 8KB
GenerateQuadtreeMesh.m 8KB
funGlobal_NodalStrainAvg.m 8KB
eps2pdf.m 8KB
ReadImageQuadtree.m 8KB
ghostscript.m 8KB
Init.m 7KB
ReadImage.m 7KB
GenerateQuadtreeMeshHole.m 7KB
IntegerSearch.m 7KB
SaveFigFilesDispAndStrain.m 6KB
fix_lines.m 6KB
SaveFigFilesDispAndStrainQuadtree.m 6KB
regularizeedges.m 6KB
gradientN.m 6KB
im2gif.m 6KB
SaveFigFiles.m 6KB
ComputeStrainQuadtree.m 6KB
Plotdisp.m 6KB
SaveFigFilesStress.m 6KB
ComputeStrain.m 6KB
rbfcreate.m 5KB
funSmoothStrain.m 5KB
QrefineRwBCNormal.m 5KB
parfor_progressbar.m 5KB
PlotdispQuadtree.m 5KB
isolate_axes.m 5KB
QrefineR.m 5KB
共 230 条
- 1
- 2
- 3
资源评论
Matlab科研辅导帮
- 粉丝: 1w+
- 资源: 7553
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于thinkphp5和layui的JTimer秒级定时任务管理设计源码
- 基于JavaScript语言Web项目图书管理系统(源代码+md说明文档)-计算机专业精品前端课程设计
- VTable 是 VisActor 可视化体系中的表格组件库,基于可视化渲染引擎 VRender 进行封装
- 基于Java的 android百度图像识别API开发的车型识别APK
- 基于Vue的轻量级开源工业物联网持续集成平台管理端设计源码
- 基于python+百度语音识别API, 读取视频文件,将视频中的语音转换成文字输出
- 斯沃数控仿真软件7.2版数控加工中心车床铣床编程仿真模拟教程斯沃系统手册凯恩帝100T
- 腾讯云 Web 超级播放器 JS 引用库
- 19道MySQL分库分表高频题整理(附答案背诵版).md
- 基于PyQt5做界面,使用百度文字识别API接口来实现识别图片中的文字,可以采用截图和浏览图片文件方式进行
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功