help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: image on sphere


From: Carnë Draug
Subject: Re: image on sphere
Date: Mon, 19 Nov 2012 23:54:01 +0000

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,  <address@hidden> wrote:
> Dnia 20 listopada 2012 0:25 Carnë Draug <address@hidden>
> 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, <address@hidden> wrote:
>>> Dnia 20 listopada 2012 0:07 Carnë Draug <address@hidden>
>>> napisał(a):
>>>
>>>
>>> On 19 November 2012 23:01, Carnë Draug <address@hidden> wrote:
>>>> On 19 November 2012 22:08, Juan Pablo Carbajal <address@hidden>
>>>> 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 <address@hidden> wrote:
> On Tue, Nov 20, 2012 at 12:25 AM, Carnë Draug <address@hidden> 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ë


reply via email to

[Prev in Thread] Current Thread [Next in Thread]