How can I prevent IMSHOW from automatically reducing the size of an image?
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to put text annotation on a 1280x1024 image. First I use IMSHOW to display the image and then use the TEXT function to create text annotations. Then I use the GETFRAME function to get a snapshot of the image with text annotation. When displaying the image with IMSHOW, it sends the following warning message
"Warning: Image is too big to fit on screen; displaying at 67%"
and reduces the size of the image to fit on the screen.
The problem I have is that I want to keep the image with text annotation the same size as the original image. When I use the GETFRAME function, it gets the reduced size image. I am fine with the image being bigger than the screen.
I tried the following command but it still does not work:
imshow(image,'border','tight','InitialMagnification',100);
Is there way to display an image without having it reduced to fit the screen?
Is there a better way to add text annotation to an image without have to display it?
0 Kommentare
Antworten (2)
Walter Roberson
am 13 Nov. 2012
If the image is larger than the screen then it cannot all be displayed at one time. getframe() works based upon what is on the screen, not based upon a virtual plot in memory, so if you did manage to display the image full scale, getframe() would end up cutting off part of it. And if you are okay with that then only display the cropped image to start with.
For your task I suggest you see http://www.mathworks.com/matlabcentral/fileexchange/19896-convert-text-to-an-image
0 Kommentare
Image Analyst
am 13 Nov. 2012
Unfortunately I don't believe it's possible. The InitialMagnification parameter doesn't seem to work if the image is larger than the screen, though I don't know why. It's ambiguous - it says
"On initial display, imshow always displays the entire image. If the magnification value is large enough that the image would be too big to display on the screen, imshow warns and displays the image at the largest magnification that fits on the screen. By default, the initial magnification parameter is set to the value returned by iptgetpref('ImshowInitialMagnification')."
However if you do it twice (thinking that maybe it only does it for the INITIAL display but not the second call to display it), it still does not change the magnification. In fact, setting the value to 200, 300, etc. won't work either. It always seems to be 'fit' if the image is larger than the screen.
However there is a workaround, though it's not really that great. There's some good news and some bad news. The good news is that you can use the zoom() function to increase the magnification. The bad news is that zoom was not meant for images and so the zoom is not absolute. It's relative to the current zoom, and even worse, it's difficult to figure out what the current zoom is. You can try this code:
set(gca, 'Units', 'Pixels')
p = get(gca, 'Position')
[rows columns, numberOfColorChannels] = size(grayImage)
zoomX = p(3)/columns % Actual zoom, e.g. 0.3333
zoomY = p(4)/rows
zoom(1/zoomX); % Zoom to 100%, e.g. zoom(3)
1 Kommentar
Walter Roberson
am 13 Nov. 2012
zoom() is implemented by changing the XLim and YLim -- you can track the relevant code down if you are persistent enough. The rest of the code for zoom() mostly has to do with remembering the original limits.
Note that changing the XLim and YLim does not enlarge the current window, just changes what is shown in that window.
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!