MATLAB编程笔记

指定x,y轴标签格式(即数字格式、单位等),参考help:Change Tick Marks and Tick Labels of Graph——h=gca; h.XTickLabel(...);

@ 之前写数据到excel中时出现错误“错误使用 xlswrite (line 219);错误: 服务器出现意外情况。——福昕阅读器占用了COM端口,在excel中去掉就行了(点击管理旁边的下拉菜单,选择COM加载项,点击转到,把福昕阅读器的前面的勾去掉,然后确定

@ MATLAB把“x”数据写到excel,xlswrite(path,x),x是一维列向量则竖着写,x是一维行向量则横着写

@ subplot(221)容易出现错误:错误使用 subplot (line 109);需要使用有效的轴句柄作为输入。——改成subplot(2,2,1)

@ mapminmax( )函数是把矩阵每一行数值处理到对应范围,不是整个矩阵处理到对应范围,不要用来做矩阵归一化。

@ MATLAB显示图的x,y与图像矩阵坐标x,y相反:在表示图像矩阵行列坐标时,x表示行数,y表示列数;在显示出来的MATLAB图像中,任意点一个点,行坐标对应y,列坐标对应y

@只保存不显示图像:h=figure;set(h,'visible','off') ;

1、VLFeat开源库

VLFeat是一个跨平台的开源机器视觉库,它囊括了当前流行的机器视觉算法,如SIFT, MSER, HOG, 同时还包含了诸如K-MEANS, Hierarchical K-means的聚类算法。它由C语言编写,并提供了Matlab接口及详细的文档。当前最新的版本是VLFeat 0.9.18 。

2、保存图像

http://blog.csdn.net/holybin/article/details/39502077

3、regionprops()函数

http://www.cnblogs.com/einyboy/archive/2012/08/03/2621820.html

 

STATS = regionprops(BW, properties)measures a set of properties for each connected component (object) in the binary image, BW. The image BW is a logical array; it can have any dimension.度量BW中具有某种属性的连通分量。BW是逻辑数组The image BW is a logical array; it can have any dimension.度量BW中具有某种属性的连通分量。BW是逻辑数组
STATS = regionprops(CC, properties) measures a set of properties for each connected component (object) in CC, which is a structure returned by bwconncomp. which is a structure returned by bwconncomp.
STATS = regionprops(L, properties) measures a set of properties for each labeled region in the label matrix L. Positive integer elements of L correspond to different regions. For example, the set of elements of L equal to 1 corresponds to region 1; the set of elements of L equal to 2 corresponds to region 2; and so on.度量label矩阵L中具有某种属性的标记区域,正整数元素相当于不同区域,例如L中等于1的所有元素属于1区域,等于2的元素属于2区域。Positive integer elements of L correspond to different regions. For example, the set of elements of L equal to 1 corresponds to region 1; the set of elements of L equal to 2 corresponds to region 2; and so on.度量label矩阵L中具有某种属性的标记区域,正整数元素相当于不同区域,例如L中等于1的所有元素属于1区域,等于2的元素属于2区域。
STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input to regionprops—either BW, CC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW), CC.ImageSize, or size(L).度量图像I中具有某特性的每个标记区域,regionprops函数第一个输入(BW,CC,L)表示图像I,
STATS is a structure array with length equal to the number of objects in BW, CC.NumObjects, or max(L(:)). The fields of the structure array denote different properties for each region, as specified by properties

4、logical类型:

 

L = logical(A) converts numeric input A into an array of logical values. Any nonzero element of input A is converted to logical 1 (true) and zeros are converted to logical 0 (false). Complex values and NaNs cannot be converted to logical values and result in a conversion error.

5、一次性处理多幅图片,新建文件夹保存每次处理结果图片

 

[fname,pname]=uigetfile('*.bmp;*.png;*.jpg','pick picture file','MultiSelect', 'on');    %从文件夹多选要处理的图像
newImgpath = [pname(1:end-1),'result'];   %去掉‘\’加上'result'得到保存结果文件夹的路径
if ~exist(newImgpath,'dir')
    mkdir(newImgpath);  %rmdir删除文件夹不经过回收站
end
if isa(fname,'char')   %如果只选择了一幅图
    filename{1}=fname;
    ncount = 1;
else     %选了多幅图
    filename=fname;
    ncount = size(fname,2);
end
hwait=waitbar(0,'waiting...');
for k = 1:ncount
    str = fullfile(pname,filename{k});
    image=imread(str);
    .........
    result=figure;
   .........
    saveas(result,fullfile(newImgpath,filename{k}));   %将处理结果图保存在此路径newImgpath
 
end

 

6、subplot子图间隔问题——tight_subplot函数

http://cn.mathworks.com/matlabcentral/fileexchange/27991-tight-subplot-nh--nw--gap--marg-h--marg-w-

7、axes:不能用title,用xlabel、ylabel;输出文本用text
8、MATLAB常用清除命令:
clc命令,即可清空命令窗口中的内容
clf命令:清除当前figure中的内容
close命令:关闭当前打开的figure图形界面
clear命令:清空workspace中的变量
9、判断是否存在:exist
10、矩形:rectangle  ——  rectangle('position',rects,'EdgeColor','r');
11、addpath(genpath(pwd)); ——没有这句找不到放在子文件夹的函数
12、fprintf('Calculating saliency map:%d\n',k);   %k是变量
13、进度条
hwait=waitbar(0,'请等待>>>>>>>>');
for k=1:steps
    if steps-k<=5
        waitbar(k/steps,hwait,'即将完成');
        pause(0.05);
    else
        str=['正在运行中',num2str(k),'%'];
        waitbar(k/steps,hwait,str);
        pause(0.05);
    end
end
close(hwait); % 注意必须添加close函数
for k=1:steps
    if steps-k<=5
        waitbar(k/steps,hwait,'即将完成');
        pause(0.05);
    else
        str=['正在运行中',num2str(k),'%'];
        waitbar(k/steps,hwait,str);
        pause(0.05);
    end
end
close(hwait); % 注意必须添加close函数

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值