Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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 6

 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 6

"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 6

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

Subject: Interesting problem with image alpha data

From: Carlos

Date: 18 May, 2010 17:01:24

Message: 4 of 6

"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!

I had a very similar problem and it turned out to be a bug with OpenGL. I tried it on another computer and it just worked! Right now I am trying to update my OpenGL driver.

Subject: Interesting problem with image alpha data

From: Rene v B

Date: 2 Jun, 2010 14:40:08

Message: 5 of 6

Worked out for me:
rotate the picture a little bit...


"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!

Subject: Interesting problem with image alpha data

From: marcus

Date: 12 Jul, 2013 21:02:07

Message: 6 of 6

Had the same problem -- alpha would apply to isosrufaces fine, but slices through
data were a no-go.

I updated OpenGL, resintalled MATLAB...and still no luck...but then I ran across this:
=========================
olebowle wrote:

    I had the same issue.
    Have a look at: http://stackoverflow.com/questions/9959 … -the-one-i

    I simply linked sys/os/glnxa64/libstdc++.so.6.0.13 to /usr/lib/libstdc++.so and now it works fine.
==============


This did the job, but I am not exactly sure why.
Good luck.


"Michael" 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!

Tags for this Thread

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.

Contact us