简体   繁体   English

如何创建块图像?

[英]How to create block image?

I have 2000 images, the size of each is Xi=320*512 double (i=1:1:2000). 我有2000张图片,每张图片的大小是Xi = 320 * 512两倍(i = 1:1:2000)。 I want to regard each image as one block, so there are 2000 blocks, and then put them in one big image. 我想将每个图像视为一个块,因此有2000个块,然后将它们放在一个大图像中。 For each block there is a label corresponding to it, the label ranges from 1 to 10. My question is how to put the 2000 images into a big block images with a label for each block as I described above? 对于每个块,都有一个与之相对应的标签,标签的范围为1到10。我的问题是,如何如上所述将2000个图像放入带有每个块标签的大块图像中?

I have 2000 images like this. 我有2000张这样的图片。 Can anyone tell me how to put this kind of images into blocks? 谁能告诉我如何将这种图像分成块?

My comment was incorrect, reshape will not solve your problem. 我的评论不正确, reshape将无法解决您的问题。 However, I did use reshape to create an example array of images. 但是,我确实使用了reshape来创建示例图像阵列。

% Replace these with 320, 512, and 2000.
nx = 2;
ny = 3;
nz = 4;

% nz images, each of size nx by ny
images = reshape(1: nx * ny * nz, nx, ny, nz)

% Put each image into a larger image composed of n1 * n2 blocks
n1 = 2;
n2 = 2;
image = zeros(n1 * nx, n2 * ny);

% Note, nz == n1 * n2 must be true

iz = 0;
for i1 = 1: n1
    for i2 = 1: n2
        iz = iz + 1;
        image((i1 - 1) * nx + 1: i1 * nx, (i2 - 1) * ny + 1: i2 * ny) ...
            = images(:, :, iz);
    end
end

image

This creates the big block image correctly. 这样可以正确创建大块图像。 You may want to change the inner/outer order of the loops to do column-major ordering instead of row-major ordering. 您可能需要更改循环的内部/外部顺序,以进行列优先排序,而不是行优先排序。

Like paisanco, I am unsure what you want to do with labels. 像paisanco一样,我不确定您想对标签做什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM