bugGNU Octave - Bugs: bug #50708, image package: add demosaic.m

 
 

bug #50708: image package: add demosaic.m

Submitted by:  Timothy Parys <tparys>
Submitted on:  Sun Apr 2 22:46:52 2017  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Feature Request
Status: Patch SubmittedAssigned to: None
Originator Name: Timothy ParysOpen/Closed: Open
Release: 4.0.0Operating System: Any

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)

Tue Apr 11 01:58:56 2017, comment #8:

For the "if 1", that's something I saw on this page: https://www.gnu.org/software/octave/doc/interpreter/Demonstration-Functions.html

Re-reading that, it looks like that was only necessary if I were to define any functions in the demo. Since I'm not doing that, it probably doesn't belong. Also looks like I had some commented out references to subplots as well. Cleaned that out as well.

Also, just noticed the Octave convention of endif instead of end. That's an interesting difference I didn't notice until now. Thanks for the fix.

(file #40349)

Timothy Parys <tparys>
Mon Apr 10 06:18:06 2017, comment #7:

@Timothy:

Thanks for the new submission, with the tests, and the nice demo.
I am uploading a new file, based on yours with

  • typos fixes
  • add sensorAlignment = tolower(sensorAlignment); so that "BGGR" can abe used.

Why did you use "if 1" in the demo?

If there no other comments, I recommend to add this function to image package. In the future we should implement another (un-patented) method, and let the user choose, like in
https://www.mathworks.com/help/vision/ref/demosaic.html in which the user can choose the Interpolation algorithm from "Bilinear" and "Gradient-corrected linear".

(file #40346)

Avinoam Kalma <avinoam>
Project Member
Sat Apr 8 00:15:17 2017, comment #6:

So, based on comments so far, I've left the interpolation algorithm as bilinear for now, and noted in the help text that it differs from the algorithm in use by Matlab.

I've drastically redone the code to remove the multiple of 2 restriction, and have done my best to adhere to the Octave coding style guide I found online.

There should be 11 tests and a demo implemented, if anyone's curious how their digital camera sees the world. The moire patterns in the second figure are actually pretty cool looking, though seems to stress this related bug? http://savannah.gnu.org/bugs/?45372

Further feedback welcome.

(file #40327)

Timothy Parys <tparys>
Tue Apr 4 18:56:37 2017, comment #5:

I am no patent lawyer (but do have some experience in using patents). And to me this seems to be a valid US patent of the company Microsoft. (A company that has money to pay lawyers...)

I will attach the (open source) original patend document as PDF. The second last page (with "claim 1") is the most important.

The patent was filed in March 2004, and is valid since 2009. The filing date is less than 20 years ago, so I would assume that the patent is still valid today. The quoted patend is valid in the US, but there are also other members of this patent family, for other countries today (namely China, Korea, Japan, Europe and World. The last two ones aren't exactly patents).

Matlab cites the following paper (from May 2004) in its help text of the demosaic command:

So the patent submission was slightly earlier than this publication. This timing looks reasonable to me if someone really wants to hold a patent on this.

The fact that this is not patented in individual countries in Europe leads me to the sucpicion that this might not exactly be "worth" a patent. But currently some counties do have this method patented. Formally there are three ways of dealing with this:

  • pay money to Microsoft to purchase the right to use this patent
  • take Microsoft a US (and some asian) courts to fight this patent. And pay lawyers to do this fighting for you.
  • wait some (probably just 7) years, until the patent is not valid any more, at least the US patent.

The first two ways don't seem feasable to me for Octave code.

So what do we do about this? Should be just use the proposed code of Timothy, that might produce lesser quality results then the Matlab function? My vote would be: yes.

(file #40266)

Hartmut <hardy>
Mon Apr 3 22:36:30 2017, comment #4:

Malvar-He-Cutler appears patent encumbered?

https://www.google.com/patents/US7502505

Timothy Parys <tparys>
Mon Apr 3 20:12:57 2017, comment #3:

Thanks for contributing this function.

However, there are few problems:

This method uses a 5x5 filter (that's the reason for the minimal size)

  • There are no builtin self tests, as CarnĂ« noted in comment #1.

Attached a new version which (try to) fix the first 6 items.

(file #40250)

Avinoam Kalma <avinoam>
Project Member
Mon Apr 3 17:46:35 2017, comment #2:

Shouldn't the function name not read "demosaic"? (letter a and i swapped)

Hartmut <hardy>
Mon Apr 3 12:45:07 2017, comment #1:

Hi! Thank you for the submission. Could you please provide some tests?

Carnë Draug <carandraug>
Project Member
Sun Apr 2 22:46:52 2017, original submission:

Found that octave did not have an implementation of demosiac. Wrote one while toying with Bayer images. Tested in Ubuntu 16.04.

Might also affect image-acquisition, per the comments in https://sourceforge.net/p/octave/image-acquisition/ci/ee385c9a7e1b7cf1897ca9ad9a53640de5f7ab70/tree/inst/SGRBGtoRGB.m

Timothy Parys <tparys>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #40349:  demosaic.m added by tparys (6kB - text/x-objcsrc)
file #40346:  demosaic.m added by avinoam (6kB - application/octet-stream)
file #40327:  demosaic.m added by tparys (6kB - text/x-objcsrc)
file #40266:  US7502505B2.pdf added by hardy (2MB - application/pdf)
file #40250:  demosaic.m added by avinoam (3kB - application/octet-stream)
file #40238:  demosiac.m added by tparys (2kB - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by avinoam (Updated the item)
  • -unavailable- added by hardy (Posted a comment)
  • -unavailable- added by tparys (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 project members can vote.

     

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

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue Apr 11 01:58:56 2017tparysAttached File-=>Added demosaic.m, #40349
    Mon Apr 10 06:18:06 2017avinoamAttached File-=>Added demosaic.m, #40346
    Sat Apr 8 00:15:17 2017tparysAttached File-=>Added demosaic.m, #40327
    Tue Apr 4 18:56:37 2017hardyAttached File-=>Added US7502505B2.pdf, #40266
    Mon Apr 3 20:12:57 2017avinoamAttached File-=>Added demosaic.m, #40250
      Summaryimage package: add demosiac.m=>image package: add demosaic.m
    Mon Apr 3 12:45:07 2017carandraugStatusNone=>Patch Submitted
    Sun Apr 2 22:46:52 2017tparysAttached File-=>Added demosiac.m, #40238

    Back to the top


    Powered by Savane 3.1-cleanup1