文章出處
文章列表
常用功能的實現
獲取當前腳本所在目錄
current_script_dir = fileparts(mfilename('fullpath')); % 結尾不帶'/'
常用函數的說明
bsxfun
matlab函數 bsxfun淺談
bsxfun是一個matlab自版本R2007a來就提供的一個函數,作用是”applies an element-by-element binary operation to arrays a and b, with singleton expansion enabled.”
bsxfun的執行是這樣的,如果a和b的大小相同,那么c=a+b. 但如果有某維不同,且a或b必須有一個在這一維的維數為1, 那么bsxfun就將少的這個虛擬的復制一些來使與多的維數一樣。
交換矩陣通道順序
是在faster-rcnn代碼中看到的,圖像從rgb通道順序轉為bgr通道順序:
I=imread('001150.jpg'); % 三通道圖像
J=I(:,:,[3,2,1])
完整版用來debug驗證的代碼可以這樣寫:
im_name = '001150.jpg';
I=imread(im_name);
figure(1); imshow(I(:,:,1)); title('R channel');
figure(2); imshow(I(:,:,2)); title('G channel');
figure(3); imshow(I(:,:,3)); title('B channel');
J=I(:,:,[3,2,1],:);
figure(4); imshow(J(:,:,1)); title('R channel');
figure(5); imshow(J(:,:,2)); title('G channel');
figure(6); imshow(J(:,:,3)); title('B channel');
加速你的matlab代碼
http://cn.mathworks.com/matlabcentral/fileexchange/5685-writing-fast-matlab-code
列舉了利用profiler等工具的用法
文章列表
全站熱搜