在MATLAB中将彩色图像划分为块 [英] Division of a color image into blocks in MATLAB
本文介绍了在MATLAB中将彩色图像划分为块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个256X256大小的RGB图像.我需要将此RGB图像分成大小为32X32的块.每个块必须依次是一个RGB图像.我该如何在MATLAB中执行此操作,请为此提供我的代码MATLAB.
i have an RGB image of size 256X256.I need to divide this RGB image into blocks of size 32X32.each block must be in turn an RGB image.how can i do this in MATLAB.Please provide me code for this in MATLAB.
推荐答案
您可以使用 mat2cell .
out = mat2cell(image,ones(256/32,1)*32,ones(256/32,1)*32,3);
out
是8 x 8的单元格数组,每个单元格包含一个32 x 32 x 3 RGB图像.
out
is a 8-by-8 cell array, with each cell containing a 32-by-32-by-3 RGB image.
您可以以out{1,1}
的身份访问第一个块.
You can access the first block as out{1,1}
.
编辑
将repmat
更改为ones
以使代码更快.
Changed repmat
to ones
to make the code faster.
这篇关于在MATLAB中将彩色图像划分为块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文