私はそれが単なる警告であり、コードには影響しないことを知っています。しかし、私の問題はズームを行わずに画像を実際の大きさで表示する必要があることですアウトは..可能ですimshow
関数はこれを行う任意のパラメータはありますか?画像が大きすぎて画面に収まらない(MATLAB)
作業をする必要があり、すべての
私はそれが単なる警告であり、コードには影響しないことを知っています。しかし、私の問題はズームを行わずに画像を実際の大きさで表示する必要があることですアウトは..可能ですimshow
関数はこれを行う任意のパラメータはありますか?画像が大きすぎて画面に収まらない(MATLAB)
作業をする必要があり、すべての
一つの解決策は、画像を表示して、すべての画像ピクセルに対して1個のスクリーンピクセルがあるように軸の範囲を変更することですありがとう:
%# 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])
今、あなたは選択することができます手(パンツール)を開き、必要に応じて画像を移動します。
@Jonas Heidelberg:それを修正しました。 – Jonas
非常にクールです:-)。 's = warning( 'off'、 'Images:initSize:adjustmentMag');を追加することができます。 図、imshow(img); 警告;警告メッセージを避ける... –
(もはや適用されない古いコメントを削除する) –
私がすでに強調した@Jonasで与えられる解は本当に良いです。
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
あなたはおそらくこれを改善することができ、次の
%# 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
はリサイズコールバック関数である:それは数字のサイズが変更される場合処理できるように、私はいくつかのマイナーな改良を提案してみましょうさらに、図のサイズを変更すると、常に左上に戻るとは限りませんが、現在の位置は維持されます。
注w_imageとh_imageは、画像の大きさであり、そしてw_windowとh_windowは、上記回答POS(3)である場合
xlim([(w_image - w_window)/2, (w_image + w_window)/2]);
ylim([(h_image - h_window)/2, (h_image + h_window)/2]);
を使用し、(代わりに左上を示すの)画像をセンタリングし、かつそれぞれpos(4)となる。
あなたは[IMTOOL](http://www.mathworks.com/help/toolbox/images/ref/imtool.html)の使用を検討しましたか? – Amro
私はそれを試しました..それは働いていますが、 'print'を使って問題を保存するために' imshow'をしたいと思います.. 'imtool'は数字を保存することができません –
同様の質問:[MATLAB:元のサイズ](http://stackoverflow.com/questions/1427602/matlab-showing-an-image-in-its-original-size) – Amro