這是matlab圖像數(shù)據(jù)的批處理cutting,主要涉及使用imcrop函數(shù),為matlab自帶函數(shù),這個(gè)函數(shù)需要圖像的坐標(biāo)位置,即目標(biāo)的x和y值,此外還需要cutting大小的長(zhǎng)和寬。其中,目標(biāo)的x和y值可以通過ginput2函數(shù)獲得。
folder = 'D:\7-21-simplewaystems1\';
name = 'test.tif';
image_data = imread([folder,name]);
missed_circle=Click(I_missed, ;
centers_combination=[ ];
centers_combination=[centers_combination;centers;missed_circle];
n=length(centers_combination);
for i=1:n;
centers_combination(i,3)=30;% wideth of x
centers_combination(i,4)=30; % length of y
end
x1=centers_combination(:,1); % location of x
y1=centers_combination(:,2); % location of y
dx=centers_combination(:,3); % wideth of x
dy=centers_combination(:,4); % length of y
cutting ={}; % building cell
for i=1:length(dx);
cutting{i} =imcrop(image_data,maps,[x1(i,1),y1(i,1),dx(i,1),dy(i,1)]); % location of cutting photos
picName=strcat('stems',num2str(i),'.tif'); % naming the cutted stems
imwrite(cutting{i},picName); % exproting the cutted stems
end
matlab圖像數(shù)據(jù)的批處理cutting |