简体   繁体   中英

How to create block image?

I have 2000 images, the size of each is Xi=320*512 double (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. 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?

I have 2000 images like this. Can anyone tell me how to put this kind of images into blocks?

My comment was incorrect, reshape will not solve your problem. However, I did use reshape to create an example array of images.

% 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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