bugGNU Octave - Bugs: bug #60226, [octave forge] (image) psf2otf...

 
 

bug #60226: [octave forge] (image) psf2otf does not allow complex numbers for psf

Submitted by:  hhh <hhh>
Submitted on:  Sat 13 Mar 2021 09:31:24 PM UTC  
 
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  6.2.0 Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

( Jump to the original submission)

Sun 04 Apr 2021 05:05:40 PM UTC, comment #9: 

I've attached a slightly improved version (V2) of my patch that also mentions this change in the NEWS file.

Please review.

(file #51190)

Hartmut <hardy>
Sun 04 Apr 2021 03:59:14 PM UTC, comment #8: 

Attached is a patch (V1) that just allows complex input values in psf2otf, as desribed in comment #4. I have not seen any negative side effects. In the inverse function (otf2psf) complex input values are already possible, so I also added a new test to psf2otf that tests a roundtrip with those two functions using complex input values.

Please review. If noone has any objections I will push this change in a couple of weeks.

For the issue of complex input values in Matlab's imresize function I have opened a new issue: bug #60336.

(file #51189)

Hartmut <hardy>
Thu 01 Apr 2021 04:50:40 PM UTC, comment #7: 

No, imresize has the "isimage" condition, which in turn has the "isreal" condition, which I had to remove from "private/isimage.m"

hhh <hhh>
Wed 31 Mar 2021 09:31:07 PM UTC, comment #6: 

@hhh: Thanks for reporting your observations. Yes, makecform is not yet implemented in the image package, and it will probably take some time until this happens. This probably means for you, that it won't be easily possible to use Octave to run this de-blur algorithm, at least not on color images, sorry. (There are several useful color transformation functions in the Octave image package, but not the makecform family, yet.)

Do I understand you correctly, that Matlab's "imresize" function also accepts complex input images? (The Matlab help page does not document this.)

Hartmut <hardy>
Wed 31 Mar 2021 08:44:14 PM UTC, comment #5: 

Thanks, with the fix I got the next error (same problem) in imresize, I had to apply same fix also for "private/isimage.m".

Then, nearly finished with the computation, I got another error:

error: 'makecform' undefined

Seems to be this bug:
https://savannah.gnu.org/bugs/?52006
?

hhh <hhh>
Sat 27 Mar 2021 08:18:20 PM UTC, comment #4: 

@hhh: As a quick fix you could try the following:

  • load the image package: >> pkg load image
  • open the file psf2otf.m in the editor: >> edit psf2otf
  • got to line 35 and delete the isreal stuff, this line should then read like this: elseif (! isnumeric (psf))
  • save the file psf2otf.m
  • Try your application again

This might work or might not work in a useful manner. In either case it would be nice if you could report back what you experienced. (If it works fine, we might just do this change to the image package source code.)

Hartmut <hardy>
Sat 27 Mar 2021 08:01:23 PM UTC, comment #3: 

Yes, I tried to run a deblur algorithm, and got stuck because of this problem:

https://github.com/FWen/deblur-pmp

hhh <hhh>
Sat 27 Mar 2021 07:45:02 PM UTC, comment #2: 

(Sorry my last post got corrupted, here is the full text again:)
-----
Thanks for letting us know this compatibility issue in our psf2otf.

I can confirm this behavior:

  • A complex input value PSF into our psf2otf currently throws a (useful) error message: PSF  must be numeric and real.
  • The Matlab docs claim that they accept a complex PSF input. A quick test in their online Matlab confirmed this.
  • I have not found any hint in the Matlab release notes (R2016a up to today) that they changed this, so this is incompatibilit is probably there already for some time.

Question to the original reporter: Do you have a usecase where a complex input value of PSF makes sense? (I know that in the formal definition the PSF can have a phase and thus be complex, but have you met such complex PSFs in "real life"?)

Question to everyone, especially to Avinoam and Carne: When I simply remove the input test for realness of PSFs in our psf2otf (line 35 in psf2otf.m) and then run the following code using our modifued psf2otf, I then get a fully Matlab compatible result. Should we simply remove the check for realness (and the corresponding error message), or was there a good reason to have this? (The file is copywrited by Carne in 2015.)

PSF  = fspecial('gaussian',5,1) + 1i;

OTF  = psf2otf(PSF,[6 6]);
R_OTF = real(OTF);
I_OTF = imag(OTF);

Matlab_R = [ ...
1 .5923 .1039 .0232 .1039 .5923; ...
.5923 .3509 .0616 .0137 .0616 .3509; ...
.1039 .0616 .0108 .0024 .0108 .0616; ...
.0232 .0137 .0024 .0005 .0024 .0137; ...
.1039 .0616 .0108 .0024 .0108 .0616; ...
.5923 .3509 .0616 .0137 .0616 .3509] ;

Matlab_I = [ ...
25 5 -5 5 -5 5; ...
5 1 -1 1 -1 1; ...
-5 -1 1 -1 1 -1; ...
5 1 -1 1 -1 1; ...
-5 -1 1 -1 1 -1; ...
5 1 -1 1 -1 1];

maxDeltaReal = max(Matlab_R(:) - R_OTF(:))
maxDeltaImag = max(Matlab_I(:) - I_OTF(:))

Hartmut <hardy>
Sat 27 Mar 2021 07:36:20 PM UTC, comment #1: 

Thanks for letting us know this compatibility issue in psf2otf.

I can confirm this behavior:

  • A complex input value PSF into our psf2otf currently throws a (useful) error message: PSF  must be numeric and real.
  • The Matlab docs claim that they accept a complex PSF input. A quick test in their online Matlab confirmed this.
  • I have not found any hint in the Matlab release notes (R2016a up to today) that they changed this, so this is incompatibilit is probably there already for some time.

Question to the original reporter: Do you have a usecase where a complex input value of PSF makes sense? (I know that in the formal definition the PSF can have a phase and thus be complex, but have you met such complex PSFs in "real life"?)

Question to everyone, especially Avinoam:

Hartmut <hardy>
Sat 13 Mar 2021 09:31:24 PM UTC, original submission:  

I got an error:
error: psf2otf: PSF must be numeric and real

You can read here, that complex numbers are allowed:

https://de.mathworks.com/help/images/ref/psf2otf.html

hhh <hhh>

 

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

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

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

    Only project members can vote.

     

     

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-04-04 hardy Attached File- => Added psf2otf_complexinputs_V2.patch, #51190
    2021-04-04 hardy Attached File- => Added psf2otf_complexinputs_V1.patch, #51189
    2021-03-27 hardy Carbon-Copy- => Added carandraug
        Carbon-Copy- => Added avinoam
    2021-03-27 hardy Carbon-CopyRemoved avinoam> => -
    2021-03-27 hardy Carbon-Copy- => Added avinoam>
    2021-03-14 mmuetzel Carbon-CopyRemoved 102357 => -
    2021-03-14 mmuetzel Summarypsf2otf does not allow complex numbers for psf => [octave forge] (image) psf2otf does not allow complex numbers for psf

    Back to the top


    Powered by Savane 3.6