这是matlab图像数据的批处理cutting,主要涉及使用imcrop函数,为matlab自带函数,这个函数需要图像的坐标位置,即目标的x和y值,此外还需要cutting大小的长和宽。其中,目标的x和y值可以通过ginput2函数获得。
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图像数据的批处理cutting |