For example: I have an image whose resolution is 46×67 and I want to change it to 35×45…How should I do that?…any help is highly appreciated
MATLAB: How to change the image resolution
digital image processingimageimage acquisitionimage processingImage Processing Toolboximage segmentation
Related Solutions
That's exactly what my demo for normxcorr2() does. Try it:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;format compact;fontSize = 20;% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');if ~hasIPT % User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?'); reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes'); if strcmpi(reply, 'No') % User said No, so exit.
return; endend% Read in a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');baseFileName = 'peppers.png';% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);if ~exist(fullFileName, 'file') % Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file') % Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName); uiwait(warndlg(errorMessage)); return; endendrgbImage = imread(fullFileName);% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);% Display the original color image.
subplot(2, 2, 1);imshow(rgbImage, []);axis on;title('Original Color Image', 'FontSize', fontSize);% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);smallSubImage = imcrop(rgbImage, [192 82 60 52]);subplot(2, 2, 2);imshow(smallSubImage, []);axis on;title('Template Image to Search For', 'FontSize', fontSize);% Search the red channel for a match.
correlationOutput = normxcorr2(smallSubImage(:,:,1), rgbImage(:,:,1));subplot(2, 2, 3);imshow(correlationOutput, []);title('Correlation Output', 'FontSize', fontSize);[maxCorrValue, maxIndex] = max(abs(correlationOutput(:)));[ypeak, xpeak] = ind2sub(size(correlationOutput),maxIndex(1));corr_offset = [(xpeak-size(smallSubImage,2)) (ypeak-size(smallSubImage,1))];subplot(2, 2, 4);imshow(rgbImage);hold on;rectangle('position',[corr_offset(1) corr_offset(2) 50 50],... 'edgecolor','g','linewidth',2);title('Template Image Found in Original Image', 'FontSize', fontSize);
I'll take a stab at it.
There are many tmes when we see in the movies, on TV, the idea that you can get almost anything out of an image, expanding a single pixel into a perfectly clear license plate number. But there are limits to what you can see.
Sometimes, we might have a very high resolution image, hundreds of millions of pixels. But when you look at the image on your basic computer monitor, you only see the broad strokes, as if you were standing a several hundred feet away looking at the Mona Lisa. If so, then, yes, you can expand what you are looking at, essentially cropping parts of the image away. This works until you get to the point where the pixels themselves start to be noticeable. But this is NOT an increase of resolution, merely the effect of standing very close to the picture, cropping away the irrelevant parts. And some pictures are taken at a very high resolution indeed.
An increase of resolution can come about IF you have additional information about the image. If the image is assumed to be essentially a smooth surface, then we could use interpolation methods. Those interpolation mathods, IF they can assume that each pixel is smoothly related to its neighbors, then the interpolation can resolve finer details of the surface. (For an RGB image, interpolate each of the red, green, and blue channels independently.) This is not any different from sampling a sine wave at fixed intervals, then using perhaps a spline interpolant to recover the original smooth shape of the sine wave. And this might be acceptable for SOME images, but it is hardly likely to be appropriate for a general image taken essentially as a photograph. There, the image content is hardly likely to be some smooth, well behaved underlying surface. As such, a higher order interpolant that employs a smoothness assumption to recover deeper structrure makes very little sense. You cannot create signal where none exists.
There are other things you might do however. You might be able to recover information in an image in some sense, based perhaps on an assumption of a known motion blur, or perhaps a known camera artifact. This is more of an enhancement issue of course, not a resolution increase.
Also, you can use multiple images, perhaps from a video sequence, using information from all of the images to provide a finer resolution at some location.
So in general, no, from a single image, you cannot simply increase the resolution. Unless of course, you are on TV, where anything is possible.
Best Answer