Untitled
unknown
plain_text
a year ago
1.1 kB
11
Indexable
% Prompt the user to select an image file
[filename, pathname] = uigetfile({'*.png;*.jpg;*.jpeg;*.bmp;*.tif', 'Image Files (*.png, *.jpg, *.jpeg, *.bmp, *.tif)'});
if isequal(filename, 0)
disp('User selected Cancel');
return;
end
% Read the selected image
originalImage = imread(fullfile(pathname, filename));
% Ensure the image is 8-bit
if ~isa(originalImage, 'uint8')
originalImage = uint8(originalImage);
end
% Define the sizes for subsampling
sizes = [1024, 512, 256, 128, 64, 32];
numSizes = length(sizes);
% Create a new figure
figure;
% Display the original and subsampled images
for i = 1:numSizes
% Get the current size
currentSize = [sizes(i), sizes(i)];
% Subsample the image to the current size
subsampledImage = imresize(originalImage, currentSize, 'bilinear');
% Display the subsampled image
subplot(2, numSizes, i);
imshow(subsampledImage);
title(sprintf('%d x %d', sizes(i), sizes(i)));
end
% Display the original image
subplot(2, numSizes, numSizes + 1);
imshow(originalImage);
title('Original 1024 x 1024 Image');
Editor is loading...
Leave a Comment