您的位置:首页 > 编程语言 > MATLAB

图像切割matlab程序

2018-03-28 16:28 232 查看
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




原图:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: