Getting image only to popup

Here is what I need
I just want the image to appear just like a picture, without anything around it.
Here the part of the code
while n<=0 %Error tester
sun = imread('index.jpeg');
imshow(sun);
Thank you
n=inputdlg({'7'});%Just an example
n=str2double(n);
end
Thank you everyone for the help

2 件のコメント

Jan
Jan 2012 年 3 月 20 日
What does "without anything around it" exactly mean? A full screen image? No window border? No grey area between the image and the window border?
Rooy
Rooy 2012 年 3 月 20 日
I uploaded an image of what I really mean, thank you

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2012 年 3 月 20 日

0 投票

It is possible to get rid of the taskbar, but not the box. It is not possible in MATLAB to create an image that is not within a figure. The figure might be nearly the same size as the image, but it will still form a box around the image.
Are you trying to get the image to appear within the popup? Your sample does not show a popup: it shows what appears to be a inputdlg().

6 件のコメント

Rooy
Rooy 2012 年 3 月 20 日
I am trying to get the image to appear with the input dialog, just the image
Walter Roberson
Walter Roberson 2012 年 3 月 20 日
Are you asking to create something similar to inputdlg() which shows an image inside the prompt box, as well as providing space for the user to give their input?
Are you asking to create a method of popping up _just_ an image, with as little decoration as you can?
To pop up an image with as little decoration as you can, then you can use this (completely untested) code:
function popupimage(ImageFileName)
if ~exist(ImageFileName,'file')
error('Asked to display non-existent image');
end
im = imread(ImageFileName);
imsize = size(im);
rows = imsize(1); cols = imsize(2);
screensize = get(0,'screensize');
rowpos = fix((screensize(3) - rows)/2);
colpos = fix((screensize(4) - cols)/2);
imfig = figure('Units','pixels','Position',[rowpos colpos rows cols], 'menubar', 'none', 'Name', InputFileName', 'NumberTitle', 'off', 'Toolbar', 'none');
imaxes = axes('Parent', imfig, 'Box', 'off', 'Units', 'normal', 'Position', [0 0 1 1], 'Visible', 'off');
image(im, 'Parent', imaxes);
axis(imaxes, 'image');
end
Rooy
Rooy 2012 年 3 月 21 日
Here is what I need http://img42.imageshack.us/img42/7427/94164198.png
Rooy
Rooy 2012 年 3 月 21 日
I had this error while using your function:
I tried that too but it does not work
Error using popupimage
Too many output arguments.
Error in Pop (line 1)
imagedisp=popupimage('index.jpeg')
I copied the code right, so I can't see anything else wrong.
Thank you
Walter Roberson
Walter Roberson 2012 年 3 月 21 日
My code does not define any output for popupimage(): it displays the image directly.
Jan
Jan 2012 年 3 月 22 日
@Zachary: Have you seen my answer? It *is* possible to get rid of all parts of the figure.

サインインしてコメントする。

その他の回答 (3 件)

Image Analyst
Image Analyst 2012 年 3 月 20 日

0 投票

Try this (assuming it's all the gray surround that you don't like/want):
How do I add a background image to my GUI or figure window?

9 件のコメント

Rooy
Rooy 2012 年 3 月 21 日
my main objetive is not to have the figure bar, thanks anyway
Image Analyst
Image Analyst 2012 年 3 月 21 日
Well turn the menubar and toolbar off like Walter showed. I ran Walter's code and it gives what you want except that it has a titlebar. But I think I remember seeing a discussion earlier where people said that was difficult or impossible to get rid of. Perhaps if you use DirectX, but do you really want to go through all that trouble? What's wrong with Walter's solution? Why can't you live with that?
Rooy
Rooy 2012 年 3 月 21 日
Am I doing something wrong , I tried it but it does not work
imagedisp=popupimage(index)
my file name is :index
type of file:jpeg
I am kind of new to function so please bare with me
Image Analyst
Image Analyst 2012 年 3 月 21 日
popupimage() takes a filename string, like 'cameraman.tif'
Rooy
Rooy 2012 年 3 月 21 日
I tried that too but it does not work
Error using popupimage
Too many output arguments.
Error in Pop (line 1)
imagedisp=popupimage('index.jpeg')
I copied the code right, so I can't see anything else wrong.
Thank you
Image Analyst
Image Analyst 2012 年 3 月 21 日
Like Walter said, just try:
popupimage('index.jpeg');
If you want a return argument (that is, imagedisp), you'd need add a return argument to the "function" line of code, like this:
function im = popupimage(ImageFileName)
If you do that, then you can do it the way you did it.
Rooy
Rooy 2012 年 3 月 21 日
I did try just using popupimage(index.jpeg) in a script file but it keeps giving me an error
Error in popupimage (line 11)
imfig = figure('Units','pixels','Position',[rowpos colpos rows cols], 'menubar', 'none',
'Name', InputFileName, 'NumberTitle', 'off', 'Toolbar', 'none');
Error in Pop (line 1)
popupimage('index.jpeg')
Image Analyst
Image Analyst 2012 年 3 月 21 日
Change InputFileName in the figure() call to ImageFileName
Rooy
Rooy 2012 年 3 月 22 日
At last, it works, thank you very much

サインインしてコメントする。

Walter Roberson
Walter Roberson 2012 年 3 月 21 日

0 投票

Your desired output cannot be achieved in MATLAB, unless perhaps it can be done by using the JAVA level. Images must appear within figures in MATLAB, and figures always have frames in MATLAB: they cannot be borderless.
It is also difficult to get rid of the window controls (resize / minimize / close); I do not know if it can be done in MS Windows.

4 件のコメント

Rooy
Rooy 2012 年 3 月 21 日
can't seem to get your function to work, if you don't mind could you show me an example, so that I can see where I am going wrong.
Thank you for all the help
Walter Roberson
Walter Roberson 2012 年 3 月 21 日
The code I gave was "To pop up an image with as little decoration as you can" and was not designed to act as an input routine. That "popupimage" routine cannot be used to return a value to the calling routine: it was designed for a different purpose.
Your design requirement *as given in your imageshack image* is something that cannot be achieved in MATLAB.
Rooy
Rooy 2012 年 3 月 21 日
I get that what I was asking is not possible in Mathlab but I wanted to try out your code but it does not work. How would I use it properly?
Thank you
Jan
Jan 2012 年 3 月 21 日
Matlab, the program is called Matlab.

サインインしてコメントする。

Jan
Jan 2012 年 3 月 21 日

0 投票

If you are working under Windows, FEX: WindowAPI let you crop an arbitrary rectangle from the figure. Use the pixel position of the axes to hide everything but the image:
set(AxesHandle, 'Units', 'pixels');
WindowAPI(FigureHandle, 'Clip', get(AxesHandle, 'Position'));
You can access, e.g. close, the window from the commandline only afterwards:
delete(gcf);

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by