Thread Subject: Why so much gray surround in a figure showing an image?

Subject: Why so much gray surround in a figure showing an image?

From: Mark

Date: 13 May, 2008 19:36:03

Message: 1 of 2

When I create a figure and use imshow() to show an image,
why is there so much wasted space surrounding the image?
Why can't it fit the image to the figure? For example,
run the following code:

% Image Processing Toolkit required for this code.
close all;
windowWidth = 20;
hsize = [windowWidth windowWidth];
sigma = 10;
kernel = fspecial('gaussian', hsize, sigma);
grid = zeros(41, 11);
grid(11, 6) = 1;
grid(32, 6) = 1;
twoGaussians = imfilter(grid, kernel);
figure;
imshow(twoGaussians, []);

Now look at the figure. The image is a tiny little
rectangle in a huge sea of gray. Even if you grab the
corner and make the figure window bigger, it's still
surrounded by an enormous amount of wasted space. Any way
to prevent this and make it sensibly size the image into
the figure?
Thanks,
Mark

Subject: Why so much gray surround in a figure showing an image?

From: helper

Date: 13 May, 2008 22:34:02

Message: 2 of 2

"Mark " <hayworth@none.com> wrote in message <g0cqj3$8f9
$1@fred.mathworks.com>...
> When I create a figure and use imshow() to show an image,
> why is there so much wasted space surrounding the image?
> Why can't it fit the image to the figure? For example,
> run the following code:
>
> % Image Processing Toolkit required for this code.
> close all;
> windowWidth = 20;
> hsize = [windowWidth windowWidth];
> sigma = 10;
> kernel = fspecial('gaussian', hsize, sigma);
> grid = zeros(41, 11);
> grid(11, 6) = 1;
> grid(32, 6) = 1;
> twoGaussians = imfilter(grid, kernel);
> figure;
> imshow(twoGaussians, []);
>
> Now look at the figure. The image is a tiny little
> rectangle in a huge sea of gray. Even if you grab the
> corner and make the figure window bigger, it's still
> surrounded by an enormous amount of wasted space. Any
way
> to prevent this and make it sensibly size the image into
> the figure?
> Thanks,
> Mark

I don't have the image processing toolbox, so I can't run
your code, but if you are talking about the area outside
the axes, try this command:

set(gca,'position',[0 0 1 1])

Once you have done that, look into the documentation for
AXES and specifically the "Position" and "Units" properties.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
imshow Mark 13 May, 2008 15:40:24
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com