图像切割matlab程序
程序员文章站
2024-03-15 08:38:59
...
clc;
clear all;
[pathname,filename] = uigetfile('*.*','选择图片','E:\裂纹\NG2裂纹\');
src_path =strcat(filename,pathname) ;
dst_path = 'E:\学习资料\MATLAB程序\裂纹分割\';
if ~exist('E:\学习资料\MATLAB程序\裂纹分割\')
mkdir('E:\学习资料\MATLAB程序\裂纹分割\');
end
A = imread(src_path);
figure;
imshow(A);
[m,n,l] = size(A);
a = 8;
figure;
for i = 1:a
for j = 1:a
m_start = 1+ (i-1)*fix(m/a);
m_end = i*fix(m/a);
n_start = 1+ (j-1)*fix(m/a) ;
n_end = j*fix(n/a);
AA = A(m_start:m_end,n_start:n_end,:);
imwrite(AA,[dst_path num2str(i) '_' num2str(j) '.jpg'],'jpg');
subplot(8,8,(i-1)*8+j);
imshow(AA);
hold on;
end
end
原图:
上一篇: pandas 如何分割字符
下一篇: NOI:7909 统计数字