Wilmar Rengifo
Wilmar Rengifo

Reputation: 1

Concatenating a Images in a matrix with other matrix images in MatLab

I want concatenate some matrix, the elements in the matrix are images. I want to concatenate thos matriz to draw a long image.

A matrix is: Matrix: Image 1

And if i concatenate it I obtain:

Matrix: Image 2

Instead of something like :

Matrix: Image 3

I attach my code. THANKS in advance.


    interrogante = imread('imagenes mario/beetle.png');
    ladrillo = imread('imagenes mario/piedr.png');

    scenario_ancho = 64 ;
    scenario_largo = 32 ;
    ancho_pixel = 16;
    total_cuadricula = scenario_ancho * scenario_largo; 
    filas_piso = 4;

    %Datos de segmento 1 -------
    ancho_segmento_1 = 4;
    altos_segmento_1 = 8;
    total_cuadricula_seg = ancho_segmento_1 * altos_segmento_1; 
    var_fila_piso_seg = filas_piso * ancho_segmento_1;
    vacio_sobre_piso_seg = (total_cuadricula_seg - var_fila_piso_seg) + 1;

    %Datos de segmento 2 -------
    ancho_segmento_2 = 4;
    altos_segmento_2 = 8;

    whiteImage = 0 * ones(ancho_pixel, ancho_pixel, 'uint8');


    var_fila_piso = filas_piso * ancho_segmento_1;
    vacio_sobre_piso = (total_cuadricula - var_fila_piso) + 1;

       for i = 1 : vacio_sobre_piso_seg
           I{i} = cat(4,whiteImage);
       end

       for j = 1 : var_fila_piso_seg
           I{i} = cat(4,ladrillo);
           i = i +1;
       end

       for i = 1 : 32
           %%filename = 'imagenes mario/beetle.png';
           H{i} = cat(4,whiteImage);
       end

    A = reshape(I,[8 4]);
    B = reshape(H,[8 4]);

    C = horzcat(A,A);

    montage(C, 'Size', [8 8]);

    disp(C);

Upvotes: 0

Views: 41

Answers (0)

Related Questions