如何在matlab中将图像分割为64块
我想计算每个图像的颜色布局描述符(CLD)。该算法包括四个阶段。在第一阶段,我必须将每个图像划分为 64 个块 i(8×8)n 以便从每个块计算单个代表颜色。我尝试使用(For 循环)将图像划分为 64 个块,但我得到 64婷图像。我想获得具有(8×8)块的图像,以便通过应用DCT变换然后Zigzag扫描来完成算法
I want to compute the Color Layout Descriptor (CLD) for each image.. this algorithm include four stages . in the First stage I must Partition each image into 64 block i(8×8)n order to compute a single representative color from each block .. I try to partition the image into 64 block by using (For loop) but I get 64 ting image. I want to get image with (8×8) block in order to complete the algorithm by apply the DCT transformation then Zigzag scanning
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将图像分区为块然后对其运行一些处理的一种方法是使用内置函数 BLOCKPROC(在旧版本的 Matlab 中称为
blkproc
)。myFunction
是您要应用于每个块的函数。您可以将其定义为代码的子函数、单独的 m 文件或匿名函数。输出将连接在 8x×8x 数组中,其中 x 是函数输出的大小。myFunction
应该有一个输入参数blockStruct
,它是一个结构体,其字段data
包含块的像素值,以及字段边框
、blockSize
、imageSize
和位置
。One way to partition your image into blocks and then run some processing on it is to use the built-in function BLOCKPROC (called
blkproc
in older versions of Matlab).myFunction
is the function that you'd like to apply to each block. You can define it as a subfunction of your code, or a separate m-file, or an anonymous function. The output will be catenated in an 8x-by-8x array, where x is the size of the output of your function.myFunction
should expect a single input argument,blockStruct
, which is a structure with fieldsdata
containing the pixel values of the block, as well as fieldsborder
,blockSize
,imageSize
, andlocation
.这里是我不久前为完全相同的问题(8x8 块、DCT 系数等)编写的一些代码...
slide_len
设置一个块与下一个块之间的偏移量。在这种情况下,它每次偏移一个像素。但是,如果您想要不重叠的块,则应将其设置为 8。通常在此应用程序中,您会使用一些重叠。Here some pieces of code that I wrote for the exact same problem (8x8 blocks, DCT coefficients, etc) sometime ago...
slide_len
sets the offset between one block and the next. In this case it offsets by one pixel each time. however, if you want non-overlapping blocks, you should set it to 8. usually in this application, you use some overlaps.