image on sphere

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

image on sphere

gregortjw
Hi,
I have a little problem.
I want to put an image on sphere like this: http://angeljohnsy.blogspot.com/2012/03/text-on-sphere-matlab-code.html
The code from matlab didn't work because of function rgb2ind .

Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Juan Pablo Carbajal-2
On Mon, Nov 19, 2012 at 9:16 PM, gregortjw <[hidden email]> wrote:

> Hi,
> I have a little problem.
> I want to put an image on sphere like this:
> http://angeljohnsy.blogspot.com/2012/03/text-on-sphere-matlab-code.html
> The code from matlab didn't work because of function rgb2ind .
>
>
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/image-on-sphere-tp4646786.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave

What is the error you are getting?
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Juan Pablo Carbajal-2
Please:
1. Keep the mailing list always in CC
2. Answer at the bottom of the message

More at the bottom...

On Mon, Nov 19, 2012 at 10:16 PM,  <[hidden email]> wrote:

> I receive communicate from console:
> error: Invalid call to rgb2ind.  Correct usage is:
>
>  -- Function File: [X, MAP] = rgb2ind (RGB)
>  -- Function File: [X, MAP] = rgb2ind (R, G, B)
>
>
> Additional help for built-in functions and operators is
> available in the on-line version of the manual.  Use the command
> `doc <topic>' to search the manual index.
>
> Help and information about Octave is also available on the WWW
> at http://www.octave.org and via the [hidden email]
> mailing list.
> octave:12>
> sorry for my english and thank you very much for quick answer :)
>
>
>
> Dnia 19 listopada 2012 22:12 Juan Pablo Carbajal <[hidden email]>
> napisał(a):
>
>
>
> On Mon, Nov 19, 2012 at 9:16 PM, gregortjw <[hidden email]> wrote:
>> Hi,
>> I have a little problem.
>> I want to put an image on sphere like this:
>> http://angeljohnsy.blogspot.com/2012/03/text-on-sphere-matlab-code.html
>> The code from matlab didn't work because of function rgb2ind .
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://octave.1599824.n4.nabble.com/image-on-sphere-tp4646786.html
>> Sent from the Octave - General mailing list archive at Nabble.com.
>> _______________________________________________
>> Help-octave mailing list
>> [hidden email]
>> https://mailman.cae.wisc.edu/listinfo/help-octave
>
> What is the error you are getting?
>
>
>
>

Post the simplest code that reproduces your problem here
http://agora.octave.org/snippet/

From the error you sent it is simply that you are calling rgb2ind incorrectly
The code you send in the link uses

[mytext,map]=rgb2ind(A,256);

But as you see from the error rgb2ind in Octave can't be called like
that. You have ti understand what is that line supposed to do and then
do the equivalent in Octave.
Hope that helps.

Cheers
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

gregortjw
I posted my code on Agora
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Juan Pablo Carbajal-2
On Mon, Nov 19, 2012 at 10:42 PM, gregortjw <[hidden email]> wrote:

> I posted my code on Agora
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/image-on-sphere-tp4646786p4646789.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave

Good!

Please send us the link, so we can check it.
Just copy the url from your web browser.

Thanks
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

gregortjw
In reply to this post by gregortjw
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Juan Pablo Carbajal-2
On Mon, Nov 19, 2012 at 10:50 PM, gregortjw <[hidden email]> wrote:

> http://agora.octave.org/snippet/WYPX/
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/image-on-sphere-tp4646786p4646792.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave

Yes, the problem is in line 2.
what is this line supposed to do?
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

gregortjw
I rewrited this line and whole code from matlab.
rgb2ind convert an image to index image
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Juan Pablo Carbajal-2
In reply to this post by Juan Pablo Carbajal-2
On Mon, Nov 19, 2012 at 11:06 PM,  <[hidden email]> wrote:

> I rewrited this line and whole code from matlab.
> rgb2ind convert an image to index image
> Dnia 19 listopada 2012 22:59 Juan Pablo Carbajal <[hidden email]>
> napisał(a):
>
>
>
> On Mon, Nov 19, 2012 at 10:50 PM, gregortjw <[hidden email]> wrote:
>> http://agora.octave.org/snippet/WYPX/
>>
>>
>>
>> --
>> View this message in context:
>> http://octave.1599824.n4.nabble.com/image-on-sphere-tp4646786p4646792.html
>> Sent from the Octave - General mailing list archive at Nabble.com.
>> _______________________________________________
>> Help-octave mailing list
>> [hidden email]
>> https://mailman.cae.wisc.edu/listinfo/help-octave
>
> Yes, the problem is in line 2.
> what is this line supposed to do?
>
>
>
>

Yes, that is ok. But when called with two arguments, what it is supposed to do?
Would you mind joining the IRC channel http://webchat.freenode.net/
go to #octave channel
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Juan Pablo Carbajal-2
In reply to this post by Juan Pablo Carbajal-2
On Mon, Nov 19, 2012 at 10:59 PM, Juan Pablo Carbajal
<[hidden email]> wrote:

> On Mon, Nov 19, 2012 at 10:50 PM, gregortjw <[hidden email]> wrote:
>> http://agora.octave.org/snippet/WYPX/
>>
>>
>>
>> --
>> View this message in context: http://octave.1599824.n4.nabble.com/image-on-sphere-tp4646786p4646792.html
>> Sent from the Octave - General mailing list archive at Nabble.com.
>> _______________________________________________
>> Help-octave mailing list
>> [hidden email]
>> https://mailman.cae.wisc.edu/listinfo/help-octave
>
> Yes, the problem is in line 2.
> what is this line supposed to do?

Your code is not fuilly Octave compatible. Apparently we have to
update rgb2ind cause it is not working as its matlab counterpart
http://agora.octave.org/snippet/rfeB/

Also note that this code is not working in gnuplot for me and that the
"phong" shading is not implemented yet.

Try using the latest version of Octave 3.6.3
If you are running Windows I cannot help you much more.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Carnë Draug-2
In reply to this post by Juan Pablo Carbajal-2
On 19 November 2012 22:08, Juan Pablo Carbajal <[hidden email]> wrote:
> Yes, that is ok. But when called with two arguments, what it is supposed to do?

The current implementation of rgb2ind is incompatible with the one
from matlab. The behaviour when it has 2 arguments depends if the
second argument is a colormap or a scalar but Octave currently
supports none of them. Plus, rgb2ind is completely broken since it
does not even return a valid colormap (exception made for rgb of class
double which I find to be very rare). I have submitted some patches
that will at least fix that last week
https://savannah.gnu.org/bugs/?37712

But supporting the other arguments as with matlab will require some
extra input checking if we don't want to break current code (which may
try to pass each channel as independent variables).

Carnë
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Carnë Draug-2
On 19 November 2012 23:01, Carnë Draug <[hidden email]> wrote:

> On 19 November 2012 22:08, Juan Pablo Carbajal <[hidden email]> wrote:
>> Yes, that is ok. But when called with two arguments, what it is supposed to do?
>
> The current implementation of rgb2ind is incompatible with the one
> from matlab. The behaviour when it has 2 arguments depends if the
> second argument is a colormap or a scalar but Octave currently
> supports none of them. Plus, rgb2ind is completely broken since it
> does not even return a valid colormap (exception made for rgb of class
> double which I find to be very rare). I have submitted some patches
> that will at least fix that last week
> https://savannah.gnu.org/bugs/?37712
>
> But supporting the other arguments as with matlab will require some
> extra input checking if we don't want to break current code (which may
> try to pass each channel as independent variables).

Oh! But as solution to your problem, don't limit your colormap to 256
colors, just don't give a second argument. The implementation of
rgb2ind in Octave stable does not look for repeated values in the
image so you'll have a colormap 3*number of pixels in your image.

Also the colormap will be the exact intensity values of your image
which is most likely uint8 which is not a valid colormap and will make
everything white. To fix this, you can either use im2double to convert
your image (before calling rgb2ind), or you colormap.

With this two changes your code should keep working in both Matlab and Octave.

Carnë
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Carnë Draug-2
Always make reply to all and include the mailing. Also, avoid top
posting, I moved your reply to the bottom of the e-mail:

On 19 November 2012 23:14,  <[hidden email]> wrote:

> Dnia 20 listopada 2012 0:07 Carnë Draug <[hidden email]>
> napisał(a):
>
>
> On 19 November 2012 23:01, Carnë Draug <[hidden email]> wrote:
>> On 19 November 2012 22:08, Juan Pablo Carbajal <[hidden email]>
>> wrote:
>>> Yes, that is ok. But when called with two arguments, what it is supposed
>>> to do?
>>
>> The current implementation of rgb2ind is incompatible with the one
>> from matlab. The behaviour when it has 2 arguments depends if the
>> second argument is a colormap or a scalar but Octave currently
>> supports none of them. Plus, rgb2ind is completely broken since it
>> does not even return a valid colormap (exception made for rgb of class
>> double which I find to be very rare). I have submitted some patches
>> that will at least fix that last week
>> https://savannah.gnu.org/bugs/?37712
>>
>> But supporting the other arguments as with matlab will require some
>> extra input checking if we don't want to break current code (which may
>> try to pass each channel as independent variables).
>
> Oh! But as solution to your problem, don't limit your colormap to 256
> colors, just don't give a second argument. The implementation of
> rgb2ind in Octave stable does not look for repeated values in the
> image so you'll have a colormap 3*number of pixels in your image.
>
> Also the colormap will be the exact intensity values of your image
> which is most likely uint8 which is not a valid colormap and will make
> everything white. To fix this, you can either use im2double to convert
> your image (before calling rgb2ind), or you colormap.
>
> With this two changes your code should keep working in both Matlab and
> Octave.
>
> would you be so kind and could you check whats wrong in this code please?
>
> A=imread('swiss.jpg');
> im2double(A);
> [mytext,map]=rgb2ind(A);
> mytext=flipud(mytext);
>
> [x,y,z] = sphere(100);
> graphics_toolkit ("fltk")
> figure(1)
> surface(x,y,z,'CData',mytext,'FaceColor','texturemap','EdgeColor','none');
>
> colormap(map/255);

Do not divide your map by 255. Next time, say what you were expecting
and what you got instead.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Juan Pablo Carbajal-2
On Tue, Nov 20, 2012 at 12:25 AM, Carnë Draug <[hidden email]> wrote:

> Always make reply to all and include the mailing. Also, avoid top
> posting, I moved your reply to the bottom of the e-mail:
>
> On 19 November 2012 23:14,  <[hidden email]> wrote:
>> Dnia 20 listopada 2012 0:07 Carnë Draug <[hidden email]>
>> napisał(a):
>>
>>
>> On 19 November 2012 23:01, Carnë Draug <[hidden email]> wrote:
>>> On 19 November 2012 22:08, Juan Pablo Carbajal <[hidden email]>
>>> wrote:
>>>> Yes, that is ok. But when called with two arguments, what it is supposed
>>>> to do?
>>>
>>> The current implementation of rgb2ind is incompatible with the one
>>> from matlab. The behaviour when it has 2 arguments depends if the
>>> second argument is a colormap or a scalar but Octave currently
>>> supports none of them. Plus, rgb2ind is completely broken since it
>>> does not even return a valid colormap (exception made for rgb of class
>>> double which I find to be very rare). I have submitted some patches
>>> that will at least fix that last week
>>> https://savannah.gnu.org/bugs/?37712
>>>
>>> But supporting the other arguments as with matlab will require some
>>> extra input checking if we don't want to break current code (which may
>>> try to pass each channel as independent variables).
>>
>> Oh! But as solution to your problem, don't limit your colormap to 256
>> colors, just don't give a second argument. The implementation of
>> rgb2ind in Octave stable does not look for repeated values in the
>> image so you'll have a colormap 3*number of pixels in your image.
>>
>> Also the colormap will be the exact intensity values of your image
>> which is most likely uint8 which is not a valid colormap and will make
>> everything white. To fix this, you can either use im2double to convert
>> your image (before calling rgb2ind), or you colormap.
>>
>> With this two changes your code should keep working in both Matlab and
>> Octave.
>>
>> would you be so kind and could you check whats wrong in this code please?
>>
>> A=imread('swiss.jpg');
>> im2double(A);
>> [mytext,map]=rgb2ind(A);
>> mytext=flipud(mytext);
>>
>> [x,y,z] = sphere(100);
>> graphics_toolkit ("fltk")
>> figure(1)
>> surface(x,y,z,'CData',mytext,'FaceColor','texturemap','EdgeColor','none');
>>
>> colormap(map/255);
>
> Do not divide your map by 255. Next time, say what you were expecting
> and what you got instead.
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave

I found that you need to divid the map by 255 otherwise you get the error
values must be in [0,1]
and the image is not shown.
With that code, it works for me.
http://agora.octave.org/snippet/rfeB/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: image on sphere

Carnë Draug-2
In reply to this post by Carnë Draug-2
Again, please do not top post and always include the mailing list on
the reply. I will not reply to you again otherwise.

On 19 November 2012 23:31,  <[hidden email]> wrote:

> Dnia 20 listopada 2012 0:25 Carnë Draug <[hidden email]>
> napisał(a):
>>
>> Always make reply to all and include the mailing. Also, avoid top
>> posting, I moved your reply to the bottom of the e-mail:
>>
>> On 19 November 2012 23:14, <[hidden email]> wrote:
>>> Dnia 20 listopada 2012 0:07 Carnë Draug <[hidden email]>
>>> napisał(a):
>>>
>>>
>>> On 19 November 2012 23:01, Carnë Draug <[hidden email]> wrote:
>>>> On 19 November 2012 22:08, Juan Pablo Carbajal <[hidden email]>
>>>> wrote:
>>>>> Yes, that is ok. But when called with two arguments, what it is supposed
>>>>> to do?
>>>>
>>>> The current implementation of rgb2ind is incompatible with the one
>>>> from matlab. The behaviour when it has 2 arguments depends if the
>>>> second argument is a colormap or a scalar but Octave currently
>>>> supports none of them. Plus, rgb2ind is completely broken since it
>>>> does not even return a valid colormap (exception made for rgb of class
>>>> double which I find to be very rare). I have submitted some patches
>>>> that will at least fix that last week
>>>> https://savannah.gnu.org/bugs/?37712
>>>>
>>>> But supporting the other arguments as with matlab will require some
>>>> extra input checking if we don't want to break current code (which may
>>>> try to pass each channel as independent variables).
>>>
>>> Oh! But as solution to your problem, don't limit your colormap to 256
>>> colors, just don't give a second argument. The implementation of
>>> rgb2ind in Octave stable does not look for repeated values in the
>>> image so you'll have a colormap 3*number of pixels in your image.
>>>
>>> Also the colormap will be the exact intensity values of your image
>>> which is most likely uint8 which is not a valid colormap and will make
>>> everything white. To fix this, you can either use im2double to convert
>>> your image (before calling rgb2ind), or you colormap.
>>>
>>> With this two changes your code should keep working in both Matlab and
>>> Octave.
>>>
>>> would you be so kind and could you check whats wrong in this code please?
>>>
>>> A=imread('swiss.jpg');
>>> im2double(A);
>>> [mytext,map]=rgb2ind(A);
>>> mytext=flipud(mytext);
>>>
>>> [x,y,z] = sphere(100);
>>> graphics_toolkit ("fltk")
>>> figure(1)
>>> surface(x,y,z,'CData',mytext,'FaceColor','texturemap','EdgeColor','none');
>>>
>>> colormap(map/255);
>>
>> Do not divide your map by 255. Next time, say what you were expecting
>> and what you got instead.
>
> I removed 255 but it doesn't work.
> error: `im2double' undefined near line 104 column 1
> I want to put an image on sphere for example the world map on sphere.
> Do you know any  way to do it in octave?

Yes. Install and load the version 2.0.0 of the image package.
im2double() did not exist before that version.

On 19 November 2012 23:33, Juan Pablo Carbajal <[hidden email]> wrote:
> On Tue, Nov 20, 2012 at 12:25 AM, Carnë Draug <[hidden email]> wrote:
>> Do not divide your map by 255. Next time, say what you were expecting
>> and what you got instead.
>
> I found that you need to divid the map by 255 otherwise you get the error
> values must be in [0,1]
> and the image is not shown.
> With that code, it works for me.
> http://agora.octave.org/snippet/rfeB/

That's because rgb2ind does not return a valid colormap, it just takes
the RGB values and returns them without scaling them to values on that
interval. This is not a problem when images are of class double
(images of class double should have only values between 0 and 1).

Dividing by 255 only works when an image if of uint8 class only. It
will fail for everything else. It's the job of im2double() to do it.

Carnë
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave