Display image zoom space in MATLAB

I have 8 images and I want to show them in the scale space format shown below. The original height and width of the image is 256. Then, on the right side of the original image at each level, the size decreases by 2. As here, the height and width of the image is 256. On the right side of the original image, the height and width are 128, 64, 32, 16, 8, 4, 2.

I have all the images in their respective sizes. I just want to know how to arrange the images according to the picture shown below. Thanks in advance.

enter image description here

+3
source share
1 answer

, . . , for, , , . , while, , .

, , 1.5 , .

, , . , for, , , , , . , , , , , . cameraman.tif , 256 x 256, , , . , imresize MATLAB, , 0.5 2. , while , , , 1. , , .

:

%// Read in image and get dimensions
im = imread('cameraman.tif');
[rows,cols] = size(im);

%// Declare output image
out = zeros(rows, round(1.5*cols), 'uint8');
out(:,1:cols) = im; %// Place original image to the left

%// Find first subsampled image, then place in output image
im_resize = imresize(im, 0.5, 'bilinear');
[rows_resize, cols_resize] = size(im_resize);
out(1:rows_resize,cols+1:cols+cols_resize) = im_resize;

%// Keep track of the next row we need to write at
rows_counter = rows_resize + 1;

%// For the rest of the scales...
while (true)
    %// Resize the image
    im_resize = imresize(im_resize, 0.5, 'bilinear');
    %// Get the dimensions
    [rows_resize, cols_resize] = size(im_resize); 
    %// Write to the output
    out(rows_counter:rows_counter+rows_resize-1, cols+1:cols+cols_resize) = ...
        im_resize;

    %// Move row counter over for writing the next image
    rows_counter = rows_counter + rows_resize;

    %// If either dimension gives us 1, there are no more scales
    %// to process, so exit.
    if rows_resize == 1 || cols_resize == 1
        break;
    end
end

%// Show the image
figure;
imshow(out);

, :

enter image description here

+4

All Articles