Thread Subject: Interesting problem with image alpha data

Subject: Interesting problem with image alpha data

From: Michael

Date: 19 Jun, 2009 08:44:02

Message: 1 of 3

 I have come across an interesting problem with setting the alpha data for an image, which I can't quite get my head around.

 To explain, consider the following example:

 h1 = figure(1);
 h1a = axes('DataAspectRatio', [1 1 1], 'DrawMode', 'fast', 'Parent', h1);
 h1b = image('Parent', h1a);

 All works as expect, then:

 set(h1b, 'CData', imread('Peppers.png')); % load a test image.

 This works just as would be expected. So, I then try:

 set(h1b, 'AlphaData', 0.75);

 Which has the right effect. However, this image isn't positioned very nicely within the axes, so I use:

 set(h1a, 'XLim', [1 512], 'YLim', [1 384], 'YDir', 'reverse');

 Which makes everything look nice. But now if I set the alpha data to anything other than 1, the image just dissappears completely. Can anyone tell me what is going wrong here?

 I'm using Matlab R2009a with version 6.3 of the Image Processing toolbox.

 Many thanks!

Subject: Interesting problem with image alpha data

From: Bill Winter

Date: 22 Sep, 2009 03:05:13

Message: 2 of 3

"Michael " <michael.bennett@lineone.net> wrote in message <h1fj4i$7ln$1@fred.mathworks.com>...
> I have come across an interesting problem with setting the alpha data for an image, which I can't quite get my head around.
>
> To explain, consider the following example:
>
> h1 = figure(1);
> h1a = axes('DataAspectRatio', [1 1 1], 'DrawMode', 'fast', 'Parent', h1);
> h1b = image('Parent', h1a);
>
> All works as expect, then:
>
> set(h1b, 'CData', imread('Peppers.png')); % load a test image.
>
> This works just as would be expected. So, I then try:
>
> set(h1b, 'AlphaData', 0.75);
>
> Which has the right effect. However, this image isn't positioned very nicely within the axes, so I use:
>
> set(h1a, 'XLim', [1 512], 'YLim', [1 384], 'YDir', 'reverse');
>
> Which makes everything look nice. But now if I set the alpha data to anything other than 1, the image just dissappears completely. Can anyone tell me what is going wrong here?
>
> I'm using Matlab R2009a with version 6.3 of the Image Processing toolbox.
>
> Many thanks!

Has anyone else seen this problem? More importantly, has anyone identified a viable solution?

Subject: Interesting problem with image alpha data

From: Loren Shure

Date: 22 Sep, 2009 11:49:30

Message: 3 of 3

In article <h99et9$5as$1@fred.mathworks.com>,
whichpart.wwinter.isnotanemail@uci.edu says...
> "Michael " <michael.bennett@lineone.net> wrote in message <h1fj4i$7ln$1@fred.mathworks.com>...
> > I have come across an interesting problem with setting the alpha data for an image, which I can't quite get my head around.
> >
> > To explain, consider the following example:
> >
> > h1 = figure(1);
> > h1a = axes('DataAspectRatio', [1 1 1], 'DrawMode', 'fast', 'Parent', h1);
> > h1b = image('Parent', h1a);
> >
> > All works as expect, then:
> >
> > set(h1b, 'CData', imread('Peppers.png')); % load a test image.
> >
> > This works just as would be expected. So, I then try:
> >
> > set(h1b, 'AlphaData', 0.75);
> >
> > Which has the right effect. However, this image isn't positioned very nicely within the axes, so I use:
> >
> > set(h1a, 'XLim', [1 512], 'YLim', [1 384], 'YDir', 'reverse');
> >
> > Which makes everything look nice. But now if I set the alpha data to anything other than 1, the image just dissappears completely. Can anyone tell me what is going wrong here?
> >
> > I'm using Matlab R2009a with version 6.3 of the Image Processing toolbox.
> >
> > Many thanks!
>
> Has anyone else seen this problem? More importantly, has anyone identified a viable solution?
>

It works for me in both R2009a and R2009b.

--
Loren
http://blogs.mathworks.com/loren

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
alpha data Michael 19 Jun, 2009 04:49:03
transparency Michael 19 Jun, 2009 04:49:03
image Michael 19 Jun, 2009 04:49:03
rssFeed for this Thread
 

MATLAB Central Terms of Use

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 Terms prior to use.

Contact us at files@mathworks.com