No bool matrices for imagesc in tip?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

No bool matrices for imagesc in tip?

Thomas Weber-8
Hi,

consider the following:

        imagesc(ones(10,10)>0)

This works in 3.0.1, but fails in current tip (8487:dc62132651db) with

imagesc(ones(10,10)>0)
error: invalid value for array property "cdata"
error: set: expecting argument 2 to be a property name
error: set: expecting argument 4 to be a property name
error: set: expecting argument 6 to be a property name
error: called from:
error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/__img__.m at line 60, column 7
error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/image.m at line 78, column 5
error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/imagesc.m at line 114, column 7
error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/imagesc.m at line 63, column 9
error: A(I): Index exceeds matrix dimension.
error: called from:
error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/__go_draw_axes__.m at line 334, column 22
error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/__go_draw_figure__.m at line 58, column 8
error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/gnuplot_drawnow.m at line 66, column 5


Casting the bool matrix to double works around this, but is this expected?

        Thomas

Reply | Threaded
Open this post in threaded view
|

Re: No bool matrices for imagesc in tip?

David Bateman-3
Thomas Weber wrote:

> Hi,
>
> consider the following:
>
> imagesc(ones(10,10)>0)
>
> This works in 3.0.1, but fails in current tip (8487:dc62132651db) with
>
> imagesc(ones(10,10)>0)
> error: invalid value for array property "cdata"
> error: set: expecting argument 2 to be a property name
> error: set: expecting argument 4 to be a property name
> error: set: expecting argument 6 to be a property name
> error: called from:
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/__img__.m at line 60, column 7
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/image.m at line 78, column 5
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/imagesc.m at line 114, column 7
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/imagesc.m at line 63, column 9
> error: A(I): Index exceeds matrix dimension.
> error: called from:
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/__go_draw_axes__.m at line 334, column 22
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/__go_draw_figure__.m at line 58, column 8
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/gnuplot_drawnow.m at line 66, column 5
>
>
> Casting the bool matrix to double works around this, but is this expected?
>
> Thomas
>
>
>  
The line concerned is

  tmp = __go_image__ (ca, "cdata", img, "xdata", xlim, "ydata", ylim,
              "cdatamapping", "direct", varargin {:});


and as img is a logical array then cdata is set from it. The next part
of the issue is that in graphics.h.in in the image class there is the code


    void init (void)
      {
    xdata.add_constraint (2);
    ydata.add_constraint (2);
    cdata.add_constraint ("double");
    cdata.add_constraint ("uint8");
    cdata.add_constraint (dim_vector (-1, -1));
    cdata.add_constraint (dim_vector (-1, -1, 3));
      }

and so cdata is required to be either a double or an uint8 array. Does
adding the line

cdata.add_constraint("logical");

help?

D.

--
David Bateman                                [hidden email]
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary

Reply | Threaded
Open this post in threaded view
|

Re: No bool matrices for imagesc in tip?

John W. Eaton-6
On 31-Oct-2008, David Bateman wrote:

| Thomas Weber wrote:
| > Hi,
| >
| > consider the following:
| >
| > imagesc(ones(10,10)>0)
| >
| > This works in 3.0.1, but fails in current tip (8487:dc62132651db) with
| >
| > imagesc(ones(10,10)>0)
| > error: invalid value for array property "cdata"
| > error: set: expecting argument 2 to be a property name
| > error: set: expecting argument 4 to be a property name
| > error: set: expecting argument 6 to be a property name
| > error: called from:
| > error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/__img__.m at line 60, column 7
| > error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/image.m at line 78, column 5
| > error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/imagesc.m at line 114, column 7
| > error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/imagesc.m at line 63, column 9
| > error: A(I): Index exceeds matrix dimension.
| > error: called from:
| > error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/__go_draw_axes__.m at line 334, column 22
| > error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/__go_draw_figure__.m at line 58, column 8
| > error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/gnuplot_drawnow.m at line 66, column 5
| >
| >
| > Casting the bool matrix to double works around this, but is this expected?
| >
| > Thomas
| >
| >
| >  
| The line concerned is
|
|   tmp = __go_image__ (ca, "cdata", img, "xdata", xlim, "ydata", ylim,
|               "cdatamapping", "direct", varargin {:});
|
|
| and as img is a logical array then cdata is set from it. The next part
| of the issue is that in graphics.h.in in the image class there is the code
|
|
|     void init (void)
|       {
|     xdata.add_constraint (2);
|     ydata.add_constraint (2);
|     cdata.add_constraint ("double");
|     cdata.add_constraint ("uint8");
|     cdata.add_constraint (dim_vector (-1, -1));
|     cdata.add_constraint (dim_vector (-1, -1, 3));
|       }
|
| and so cdata is required to be either a double or an uint8 array. Does
| adding the line
|
| cdata.add_constraint("logical");
|
| help?

Yes, that seems to fix the problem.  Will you please check in this
fix?

Thanks,

jwe

Reply | Threaded
Open this post in threaded view
|

Re: No bool matrices for imagesc in tip?

David Bateman-3
John W. Eaton wrote:
> Yes, that seems to fix the problem.  Will you please check in this
> fix?
>
>  
Ok done..

D.

--
David Bateman                                [hidden email]
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary

Reply | Threaded
Open this post in threaded view
|

Re: No bool matrices for imagesc in tip?

Michael Goffioul
In reply to this post by Thomas Weber-8
On Fri, Oct 31, 2008 at 3:46 PM, Thomas Weber
<[hidden email]> wrote:

> Hi,
>
> consider the following:
>
>        imagesc(ones(10,10)>0)
>
> This works in 3.0.1, but fails in current tip (8487:dc62132651db) with
>
> imagesc(ones(10,10)>0)
> error: invalid value for array property "cdata"
> error: set: expecting argument 2 to be a property name
> error: set: expecting argument 4 to be a property name
> error: set: expecting argument 6 to be a property name
> error: called from:
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/__img__.m at line 60, column 7
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/image.m at line 78, column 5
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/imagesc.m at line 114, column 7
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/image/imagesc.m at line 63, column 9
> error: A(I): Index exceeds matrix dimension.
> error: called from:
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/__go_draw_axes__.m at line 334, column 22
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/__go_draw_figure__.m at line 58, column 8
> error:   /home/weber/sources/vcs/mercurial/octave-build/scripts/plot/gnuplot_drawnow.m at line 66, column 5
>
>
> Casting the bool matrix to double works around this, but is this expected?

What does Matlab do?

Michael.
Reply | Threaded
Open this post in threaded view
|

Re: No bool matrices for imagesc in tip?

Thomas Weber-8
Am Freitag, den 31.10.2008, 20:08 +0000 schrieb Michael Goffioul:
> On Fri, Oct 31, 2008 at 3:46 PM, Thomas Weber
> <[hidden email]> wrote:
> What does Matlab do?

It works, and it takes a colorbar from 0 to 2.
That's Matlab 7.1.

        Thomas

Reply | Threaded
Open this post in threaded view
|

Re: No bool matrices for imagesc in tip?

Michael Goffioul
My question was badly expressed. It should have been: does
Matlab accepts that you "set(img, 'cdata', m)", where img is
an image handle and m is a bool matrix?

Michael.

On Sat, Nov 1, 2008 at 9:50 AM, Thomas Weber
<[hidden email]> wrote:

> Am Freitag, den 31.10.2008, 20:08 +0000 schrieb Michael Goffioul:
>> On Fri, Oct 31, 2008 at 3:46 PM, Thomas Weber
>> <[hidden email]> wrote:
>> What does Matlab do?
>
> It works, and it takes a colorbar from 0 to 2.
> That's Matlab 7.1.
>
>        Thomas
>
>
Reply | Threaded
Open this post in threaded view
|

Re: No bool matrices for imagesc in tip?

Thomas Weber-8
Am Samstag, den 01.11.2008, 10:14 +0000 schrieb Michael Goffioul:
> My question was badly expressed. It should have been: does
> Matlab accepts that you "set(img, 'cdata', m)", where img is
> an image handle and m is a bool matrix?

>> m = ones(10,10)>0;
>> img = figure()
>> set(img, 'cdata', m)
??? There is no 'cdata' property in the 'figure' class.

Doesn't seem so, but the version of Matlab here is not the latest.

        Thomas


Reply | Threaded
Open this post in threaded view
|

Re: No bool matrices for imagesc in tip?

Michael Goffioul
On Sat, Nov 1, 2008 at 7:15 PM, Thomas Weber
<[hidden email]> wrote:
> Am Samstag, den 01.11.2008, 10:14 +0000 schrieb Michael Goffioul:
>> My question was badly expressed. It should have been: does
>> Matlab accepts that you "set(img, 'cdata', m)", where img is
>> an image handle and m is a bool matrix?
>
>>> m = ones(10,10)>0;
>>> img = figure()
>>> set(img, 'cdata', m)
> ??? There is no 'cdata' property in the 'figure' class.

Indeed. As I mentioned, img should be an image handle, not
a figure handle.

Michael.
Reply | Threaded
Open this post in threaded view
|

Re: No bool matrices for imagesc in tip?

Søren Hauberg
lør, 01 11 2008 kl. 21:51 +0000, skrev Michael Goffioul:

> On Sat, Nov 1, 2008 at 7:15 PM, Thomas Weber
> <[hidden email]> wrote:
> > Am Samstag, den 01.11.2008, 10:14 +0000 schrieb Michael Goffioul:
> >> My question was badly expressed. It should have been: does
> >> Matlab accepts that you "set(img, 'cdata', m)", where img is
> >> an image handle and m is a bool matrix?
> >
> >>> m = ones(10,10)>0;
> >>> img = figure()
> >>> set(img, 'cdata', m)
> > ??? There is no 'cdata' property in the 'figure' class.
>
> Indeed. As I mentioned, img should be an image handle, not
> a figure handle.

The following code

  f = imshow (rand (50));
  m = ones(50)>0;  
  set(f, 'cdata', m)

works just fine, and the resulting figure is a white image. Also,

  get (f)

prints

        AlphaData = [1]
        AlphaDataMapping = none
        Annotation = [ (1 by 1) hg.Annotation array]
        CData = [ (50 by 50) logical array]
        CDataMapping = scaled
        DisplayName =
        EraseMode = normal
        XData = [1 50]
        YData = [1 50]

        BeingDeleted = off
        ButtonDownFcn =
        Children = []
        Clipping = on
        CreateFcn =
        DeleteFcn =
        BusyAction = cancel
        HandleVisibility = on
        HitTest = on
        Interruptible = off
        Parent = [171.001]
        Selected = off
        SelectionHighlight = on
        Tag =
        Type = image
        UIContextMenu = []
        UserData = []
        Visible = on

Søren

Reply | Threaded
Open this post in threaded view
|

Re: No bool matrices for imagesc in tip?

John W. Eaton
Administrator
On  1-Nov-2008, Søren Hauberg wrote:

| lør, 01 11 2008 kl. 21:51 +0000, skrev Michael Goffioul:
| > On Sat, Nov 1, 2008 at 7:15 PM, Thomas Weber
| > <[hidden email]> wrote:
| > > Am Samstag, den 01.11.2008, 10:14 +0000 schrieb Michael Goffioul:
| > >> My question was badly expressed. It should have been: does
| > >> Matlab accepts that you "set(img, 'cdata', m)", where img is
| > >> an image handle and m is a bool matrix?
| > >
| > >>> m = ones(10,10)>0;
| > >>> img = figure()
| > >>> set(img, 'cdata', m)
| > > ??? There is no 'cdata' property in the 'figure' class.
| >
| > Indeed. As I mentioned, img should be an image handle, not
| > a figure handle.
|
| The following code
|
|   f = imshow (rand (50));
|   m = ones(50)>0;  
|   set(f, 'cdata', m)
|
| works just fine, and the resulting figure is a white image. Also,

This doesn't seem to work properly in Octave.  I'm seeing a black
image.  The data does appear to be stored properly as a logical array
in the cdata image property.  Would someone familiar with the image
functions take a look at this problem?

Thanks,

jwe