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

 
 

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

Submitter:  Adam H Aitkenhead <adama>
Submitted:  Sat 06 Apr 2013 07:11:51 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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>
Group Member
Wed 08 May 2013 07:58:34 PM UTC, comment #11: 
Jordi Gutiérrez Hermoso <jordigh>
Group Member
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>
Group Member
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>
Group 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 Files:
   
   
Comment:
   

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

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-05-08 adama Attached File- Added rgb2ind_bugfix.diff, #28049
    2013-05-08 adama Attached File- Added rgb2ind_NDimages_v6.diff, #28048
    2013-05-08 jordigh StatusNone Done
        Open/ClosedOpen Closed
    2013-05-08 adama Attached File- Added rgb2ind_NDimages_v5.diff, #28047
    2013-05-07 adama Attached File- Added rgbmap_v4.m, #28040
    2013-05-06 adama Attached File- Added rgb2ind_NDimages_v4.diff, #28035
        Attached File- Added rgbmap.m, #28036
    2013-05-04 adama Attached File- Added rgb2ind_NDimages_v3.diff, #28014
    2013-05-04 adama Attached File- Added rgbmap.m, #28013
    2013-04-06 adama Attached File- Added rgb2ind_NDimages_v2.diff, #27789
    2013-04-06 adama Attached File- Added rgb2ind_NDimages.diff, #27788

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code