arraysimagematlabsubplotimage-effects

Display a Gaussian pyramid stored in a cell array in a single figure


I'm working on a Gaussian Pyramid code for matlab. Basically it loads an image, creates a cell array and fills it with different levels of the gaussian pyramid.

I want to show the content of my cell array filled with images in one single figure, so you can see the gaussian pyramid effect. Meaning the original image is at full size and the rest are downsampled by 2 each. And all that in one figure.

I'm quite the amateur when it comes to Matlab so I don't really know how to do that. I already tried it somewhat with subplots but failed.

Thanks in advance.


Solution

  • I used a loop to add zeros at the top of all images then merged them

    Sample cell,

    im = imread('peppers.png');
    for i = 1 : 5
        I{i} = im(1 : 2*i : end, 1 : 2*i : end,:); 
    end
    

    The code, I being your cell,

    m = size(I{1}, 1);
    newI = I{1};
    for i = 2 : numel(I)
        [q,p,~] = size(I{i});
        I{i} = cat(1,repmat(zeros(1, p, 3),[m - q , 1]),I{i});
        newI = cat(2,newI,I{i});
    end
    imshow(newI)
    

    enter image description here

    For 2D images use : I{i} = cat(1,repmat(zeros(1 , p),[m - q , 1]),I{i});

    enter image description here