[2] Hex to RGB.
[3] 渐变色生成器(最多10层颜色).
1 | colors=colormap(cbrewer('qual', 'Accent', N)); |
[7] 金黄色(254,254,65).
1 | colors=colormap(cbrewer('qual', 'Accent', N)); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | % Created by LI Xu % Version 1.0 % 10 May, 2016 clear; clc; % Input Image inpath='p4.png'; % Check the size of input image info=imfinfo(inpath); height=info.Height; width=info.Width; stdhgt=1280; stdwdh=720; imscale=1; if height<stdhgt || width<stdwdh disp(['This input image size is smaller than the Standard ', ... num2str(stdhgt), ' * ', num2str(stdwdh), '.']); newimg=SmallOne(inpath, stdhgt./stdwdh, 0.13); else disp(['This is a larger one.']); newimg=LargeOne(inpath, imscale, [stdhgt, stdwdh], [ .05, .35]); end otname=strsplit(inpath, '.'); otname=otname{1}; otname=[otname, '_new.png']; pause(3); imwrite(newimg, otname); close all; disp('**************************************************'); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | % Created by LI Xu % Version 1.0 % 10 May, 2016 function newimg=LargeOne(path, imscale, stdsize, stscale) img=imread(path); img=imresize(img, imscale); [row, col, ~]=size(img); rowscale=stscale(1); colscale=stscale(2); strow=rowscale*row; stcol=colscale*col; stdow=stdsize(1); stdcol=stdsize(2); newimg=img(strow:strow+stdow-1, stcol:stcol+stdcol-1, :); imshow(uint8(newimg)); end |
1 2 3 4 | ffmpeg -i input1.avi -qscale:v 1 intermediate1.mpg ffmpeg -i input2.avi -qscale:v 1 intermediate2.mpg ffmpeg -i concat:"intermediate1.mpg|intermediate2.mpg" -c copy intermediate_all.mpg ffmpeg -i intermediate_all.mpg -qscale:v 2 output.avi |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | % Created by LI Xu % Version 1.0 % April 20, 2016 % Description: % Combine several videos to one % If you have any question about this code, % please do not hesitate to contact me via E-mail: % jeremy456@163.com % Blog: % http://blog.sciencenet.cn/u/lixujeremy % http://lixuworld.blogspot.com/ clear clc % Source Directory SouDir='input'; % Destination Directory DesDir='output'; otpath=fullfile(DesDir, 'all.wmv'); % All Input Videos videos=dir(fullfile(SouDir, '*.wmv')); % Loop to convert input videos % to the mpg format disp('...Start to convert to mpg format...'); for ii=1:length(videos) vidname=videos(ii).name; [~, filename, ~]=fileparts(vidname); vidpath=fullfile(SouDir, vidname); % Mpg mpgpath=fullfile(SouDir, [filename, '.mpg']); ConToMpg(vidpath, mpgpath); end disp('...Finish to convert to mpg format...'); % All mpg Videos mpgfiles=dir(fullfile(SouDir, '*.mpg')); % Construct file path string vidstr=[]; for ii=1:length(mpgfiles) mpgname=mpgfiles(ii).name; mpgpath=fullfile(SouDir, mpgname); if isempty(vidstr) vidstr=mpgpath; else vidstr=[vidstr, '|', mpgpath]; end end disp('...Start to Concatenate...'); % Command outmpg='temporary.mpg'; cmdstr=['ffmpeg -i concat:"', vidstr, '"']; cmdstr=[cmdstr, ' -c copy ', outmpg]; [stuat, cmdout]=system(cmdstr); % Delete all mpg files DeleteMPG(SouDir, mpgfiles); % Convert to wmv ConToWMV(outmpg, otpath); delete(outmpg); disp('...Finish to Concatenate...'); disp('Exit'); disp('**************************************************'); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | % Created by LI Xu % Version 1.0 % April 19, 2016 % Description: % Clip rasters from a shapefile boundary % If you have any question about this code, % please do not hesitate to contact me via E-mail: % jeremy456@163.com % Blog: % http://blog.sciencenet.cn/u/lixujeremy % http://lixuworld.blogspot.com/ clear; clc; % Source Directory SouDir='input'; % Destination Directory DesDir='output'; % All Input Files files=dir(fullfile(SouDir, '*.tif')); % Vector File vecpath='shapefile.shp'; [~, layername, ~]=fileparts(vecpath); % Output No Data NoData=-2; % Loop for ii=1:length(files) filename=files(ii).name; filepath=fullfile(SouDir, filename); otpath=fullfile(DesDir, filename); % gdalwarp -of GTiff -cutline INPUT.shp -cl shapefile -crop_to_cutline INPUT.tif OUTPUT.tif strcmd=['gdalwarp -of GTiff -cutline ', vecpath, ' -cl ', layername, ' -crop_to_cutline ']; strcmd=[strcmd, '-dstnodata ' num2str(NoData),' ', filepath, ' ', otpath]; py.os.system(strcmd); disp([num2str(ii), ':', filename]); end disp('************************************************'); |