基于Matlab的图像分块处理

简介
在图像处理中,图像块操作是常用的操作之一。这里介绍一种分块方法。

实例

% http://blog.csdn.net/lyqmath

clc; clear all; close all;
A = imread('cameraman.tif');
info = imfinfo('cameraman.tif');
wd = info.Width;
hd = info.Height;
num = 8;
sub_wd = wd / num;
sub_hd = hd / num;
if ndims(A) == 3
    B=rgb2gray(A);%把真彩图转换为灰度图
else
    B = A;
end
B=im2double(B);
C=mat2cell(B, num*ones(1, sub_wd), num*ones(1, sub_hd));
D=reshape(C,1,[]);
for k = 1 : length(D)
    E{k}=reshape(D{k},[],1);
end
%把像素转化为1列64行的矩阵

 

----------------------------------------------------------------------------

clc; clear all; close all;
I = imread('cameraman.tif');
sz = size(I);
[x, y] = meshgrid(1:15:sz(2), 1:15:sz(1));
z = ones(size(x));
figure('units', 'normalized', 'position', [0 0 1 1], ...
    'color', [55,190,254]/255);
imshow(I, []);
hold on; axis off;
mesh(x, y, z, 'FaceColor', 'none', ...
    'EdgeColor', 'r', 'LineWidth', 2, ...
    'Marker', 'o', 'MarkerFaceColor', 'k', ...
    'MarkerSize', 5);

 

结果

  • 6
    点赞
  • 58
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值