patchGNU Octave - Patches: patch #8001, rgb2ind.m: Enable handling of ND...

 
 

patch #8001: rgb2ind.m: Enable handling of ND images

Submitted by:  Adam H Aitkenhead <adama>
Submitted on:  Sat 06 Apr 2013 07:11:51 AM UTC  
 
Category: NonePriority: 5 - Normal
Status: DonePrivacy: Public
Assigned to: NoneOpen/Closed: Closed

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Fri 10 May 2013 04:07:27 PM UTC, comment #14:

I looked at it last christmas so I may be recalling it wrong, but I think the limitation will still be there even after recompiling for different quantum-depth.

Carnë Draug <carandraug>
Project Member
Fri 10 May 2013 05:59:01 AM UTC, comment #13:

Does recompiling graphicsmagick for 16 or 32 bits (instead of the default 8) make any difference, or is it still limited to 0-255?

Adam H Aitkenhead <adama>
Thu 09 May 2013 05:29:24 PM UTC, comment #12:

I saw the dithering that GraphicsMagick uses, but if you look at their source, it only works for values in the 0-255 range. On the other hand, if someone is dithering their images, they probably don't care too much about precision.

Carnë Draug <carandraug>
Project Member
Wed 08 May 2013 07:58:34 PM UTC, comment #11:

Thanks, I've pushed the second fix:

http://hg.savannah.gnu.org/hgweb/octave/rev/8d32a887754a

Jordi Gutiérrez Hermoso <jordigh>
Project Administrator
Wed 08 May 2013 07:51:03 PM UTC, comment #10:

The attached patch applies the bugfix to the tip, so that it keeps all your style fixes. Sorry I was a bit slow at spotting this.

(file #28049)

Adam H Aitkenhead <adama>
Wed 08 May 2013 07:35:10 PM UTC, comment #9:

Sorry for the late change!! I spotted a bug for ND arrays, as Graphickmagick can only handle 2D images. This fixes it, by tiling an ND array into a 2D array before it is processed. (I can redo the patch on the latest version if that's a better way to fix it.)

(file #28048)

Adam H Aitkenhead <adama>
Wed 08 May 2013 07:00:43 PM UTC, comment #8:

Thanks, I have merged and pushed your changes with some minor style fixes:

http://hg.savannah.gnu.org/hgweb/octave/graph/ace0f60672ec

Calling graphicsmagick this way is probably not the best way to do it. I don't think this will work cross-platformly, but as an initial implementation, this is ok. We'll send future bug reports your way when users complain about this not working. ;-)

Jordi Gutiérrez Hermoso <jordigh>
Project Administrator
Wed 08 May 2013 06:48:41 PM UTC, comment #7:

I've rewritten everything so that it now uses Graphicsmagick to do the work, which makes it much faster and much better. It gets rid of the private/rgbmap.m function, which was a bit of a bodge anyway. It also means that n,tol,map and dithering are now all enabled.

(The dithering bit might be useful if you are working on the dither function Carne, if it's any help. I haven't tried it out for greyscale images though.)

I don't know if this is the best way to call Graphicsmagic, or if it would work on systems other than GNU/linux - any suggestions welcome.

Adam

(file #28047)

Adam H Aitkenhead <adama>
Tue 07 May 2013 02:10:57 PM UTC, comment #6:

Another revision of private/rgbmap.m: I've tweaked the generated colormap to give a small reduction in the mean error in the R,G and B channels. Also a bit of tidying up.

The up-to-date versions of both rgb2ind and rgbmap are now v4. (I have no other changes planned.)

(file #28040)

Adam H Aitkenhead <adama>
Mon 06 May 2013 07:21:54 PM UTC, comment #5:

Updated patch attached, along with a modified version of the private function rgbmap.m

(file #28035, file #28036)

Adam H Aitkenhead <adama>
Sun 05 May 2013 05:58:32 AM UTC, comment #4:

> Don't do this. Yes, it complicates the input check, but it will break previous code without warning. If we are removing this, then it should be deprecated first.


No problem, I'll change that bit back.

Will look forward too seeing the dither patch when it's ready. Should be quite straightforward to fit it in here.

Thanks, Adam

Adam H Aitkenhead <adama>
Sat 04 May 2013 06:25:41 PM UTC, comment #3:

> The image must now be input as a single RGB array, rather than allowing R, G, B to be input separately. This was just to simplify the handling of the inputs, now that there are additional input arguments to be handled. As far as I can tell, Matlab only allows a single RGB array as an input too. (Let me know if I'm wrong about this!)


Don't do this. Yes, it complicates the input check, but it will break previous code without warning. If we are removing this, then it should be deprecated first.

> Dithering is not implemented yet. I need to do some reading up on that before I see if I'm capable of adding that.


This should be implemented by calling dither() which is not yet implemented. I have a working patch of it, but have only implemented the grayscale to binary.

Carnë Draug <carandraug>
Project Member
Sat 04 May 2013 10:09:33 AM UTC, comment #2:

Quite a few further changes. This full list is now:

- Enable handling of ND images.
- Simplify the code which computes x,map. The function now runs in approx 0.25-0.30 of the time required by the previous implementation.
- The inputs n, tol and map are now enabled, improving compatibility with Matlab.
- The image must now be input as a single RGB array, rather than allowing R, G, B to be input separately. This was just to simplify the handling of the inputs, now that there are additional input arguments to be handled. As far as I can tell, Matlab only allows a single RGB array as an input too. (Let me know if I'm wrong about this!)
- Dithering is not implemented yet. I need to do some reading up on that before I see if I'm capable of adding that.

I got muddled up trying to work out how to amend the previous commit in hg, so I've re-done this from scratch. Also, I don't know if the new private function rgbmap.m has been included properly, so I've attached it separately too. One day I'll get the hang of hg...

Hope this is useful.
Adam

(file #28013, file #28014)

Adam H Aitkenhead <adama>
Sat 06 Apr 2013 07:18:53 AM UTC, comment #1:

Updated with more sensible variable names.

(file #27789)

Adam H Aitkenhead <adama>
Sat 06 Apr 2013 07:11:51 AM UTC, original submission:

The attached patch enables ND images in rgb2ind.m.

It also simplifies the code which checks that the RGB indices are unique.

Adam H Aitkenhead <adama>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #28049:  rgb2ind_bugfix.diff added by adama (1kB - text/x-patch)
file #28048:  rgb2ind_NDimages_v6.diff added by adama (7kB - text/x-patch)
file #28047:  rgb2ind_NDimages_v5.diff added by adama (7kB - text/x-patch)
file #28040:  rgbmap_v4.m added by adama (2kB - application/vnd.wolfram.mathematica.package)
file #28036:  rgbmap.m added by adama (2kB - text/x-objcsrc)
file #28035:  rgb2ind_NDimages_v4.diff added by adama (7kB - text/x-patch)
file #28014:  rgb2ind_NDimages_v3.diff added by adama (11kB - text/x-patch)
file #28013:  rgbmap.m added by adama (2kB - text/x-objcsrc)
file #27789:  rgb2ind_NDimages_v2.diff added by adama (2kB - text/x-patch)
file #27788:  rgb2ind_NDimages.diff added by adama (2kB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jordigh (Posted a comment)
  • -unavailable- added by adama (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 12 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 08 May 2013 07:51:03 PM UTCadamaAttached File-=>Added rgb2ind_bugfix.diff, #28049
    Wed 08 May 2013 07:35:10 PM UTCadamaAttached File-=>Added rgb2ind_NDimages_v6.diff, #28048
    Wed 08 May 2013 07:00:43 PM UTCjordighStatusNone=>Done
      Open/ClosedOpen=>Closed
    Wed 08 May 2013 06:48:41 PM UTCadamaAttached File-=>Added rgb2ind_NDimages_v5.diff, #28047
    Tue 07 May 2013 02:10:57 PM UTCadamaAttached File-=>Added rgbmap_v4.m, #28040
    Mon 06 May 2013 07:21:54 PM UTCadamaAttached File-=>Added rgb2ind_NDimages_v4.diff, #28035
      Attached File-=>Added rgbmap.m, #28036
    Sat 04 May 2013 10:09:33 AM UTCadamaAttached File-=>Added rgb2ind_NDimages_v3.diff, #28014
    Sat 04 May 2013 10:09:32 AM UTCadamaAttached File-=>Added rgbmap.m, #28013
    Sat 06 Apr 2013 07:18:53 AM UTCadamaAttached File-=>Added rgb2ind_NDimages_v2.diff, #27789
    Sat 06 Apr 2013 07:11:51 AM UTCadamaAttached File-=>Added rgb2ind_NDimages.diff, #27788

    Back to the top


    Powered by Savane 3.1-cleanup