I know that it is just a warning and it will not affect the code .. but my problem is that I need to show the image in its real size without any zooming out .. is that possible in imshow
function are there any parameters that do this?
thank you all
Use the axis image command to force the aspect ratio to be one-to-one. The axis image command works by setting the DataAspectRatio property of the axes object to [1 1 1]. See axis and axes for more information on how to control the appearance of axes objects.
There is no way to change pixel size in MATLAB, except sometimes by using operating-system specific calls to interact with the display. It is not possible on LCD displays (each LCD segment is a fixed physical size), and not possible on LED displays, and it is not possible most CRTs.
Resize the image, using the imresize function. In this example, you specify a magnification factor. To enlarge an image, specify a magnification factor greater than 1. magnificationFactor = 1.25; J = imresize(I,magnificationFactor);
Resize Indexed Image[X,map] = imread("corn. tif"); Increase the size of the indexed image by 50%. [Y,newmap] = imresize(X,map,1.5);
The solution given by @Jonas, which I already upvoted, is really good. Let me suggest some minor improvements so that it handles the case when the figure is resized:
%# read an image and make it large
img = imread('autumn.tif');
img = repmat(img, [10 10]);
%# new figure
hFig = figure;
%# try show image at full size (suppress possible warning)
s = warning('off', 'Images:initSize:adjustingMag');
imshow(img, 'InitialMagnification',100, 'Border','tight')
warning(s);
%# handle figure resize events
hAx = gca;
set(hFig, 'ResizeFcn',{@onResize,hAx})
%# call it at least once
feval(@onResize,hFig,[],hAx);
%# enable panning tool
pan on
the following is the resize callback function:
function onResize(o,e,hAx)
%# get axes limits in pixels
oldUnits = get(hAx, 'Units'); %# backup normalized units
set(hAx, 'Units','pixels')
pos = get(hAx, 'Position');
set(hAx, 'Units',oldUnits) %# restore units (so it auto-resize)
%# display the top left part of the image at magnification 100%
xlim(hAx, [0 pos(3)]+0.5)
ylim(hAx, [0 pos(4)]+0.5)
end
You could probably improve this further so that when you resize the figure, you don't always go back to the top-left corner, but maintain the current position.
One solution that should work is to display the image and then change the axes limits so that there is one screen pixel for every image pixel:
%# read an image and make it large
img = imread('autumn.tif');
img = repmat(img,[10,10]);
%# turn off the warning temporarily, we're going to fix the problem below
%# Note that in R2011b, the warning ID is different!
warningState = warning('off','Images:initSize:adjustingMag');
figure
imshow(img)
warning(warningState);
%# get axes limits in pixels
set(gca,'units','pixels')
pos = get(gca,'position')
%# display the top left part of the image at magnification 100%
xlim([0.5 pos(3)-0.5]),ylim([0.5 pos(4)-0.5])
Now you can select the hand (pan tool) and move the image around as needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With