bugGNU Octave - Bugs: bug #53309, [octave forge] (image) imrotate of...

 
 

bug #53309: [octave forge] (image) imrotate of +/-90 degrees results in black image when 'crop' and RGB image as input

Submitter:  Tis Veugen <tis>
Submitted:  Fri 09 Mar 2018 03:08:17 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * other Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 15 May 2018 06:16:37 AM UTC, comment #6: 

Thank you for the debugging and fix.

There's no need for the special handling if image is RGB.  We can just add an extra ':' for the third dimension and it will work even if that dimension is not there.  I have pushed http://hg.code.sf.net/p/octave/image/rev/70c74897a69c to fix the issue and also added some tests for the future.

Carnë Draug <carandraug>
Group Member
Mon 12 Mar 2018 09:57:53 PM UTC, comment #5: 

Thanks for reporting. Checking again, and indeed there is a bug, when the image is RGB image.

Actually there are few bug in lines 126-131 if imrotate:


      imgPost = zeros(sizePre);
      hw = min(sizePre) / 2 - 0.5;
      imgPost   (round(oPost(2) - hw) : round(oPost(2) + hw),
                 round(oPost(1) - hw) : round(oPost(1) + hw) ) = ...
          imgRot(round(oPost(1) - hw) : round(oPost(1) + hw),
                 round(oPost(2) - hw) : round(oPost(2) + hw) );


1. The class of the output image is not the same as the inputimage
2. The calculation of the parameter hw is not correct for RGB image
3. There is no treatment of RGB image

a fix could be:


      imgPost = zeros(sizePre, class (imgPre));
      hw = min(sizePre(1:2)) / 2 - 0.5;
      if (isgray(imgPre))
        imgPost   (round(oPost(2) - hw) : round(oPost(2) + hw),
                   round(oPost(1) - hw) : round(oPost(1) + hw) ) = ...
            imgRot(round(oPost(1) - hw) : round(oPost(1) + hw),
                   round(oPost(2) - hw) : round(oPost(2) + hw) );
       else
        imgPost   (round(oPost(2) - hw) : round(oPost(2) + hw),
                   round(oPost(1) - hw) : round(oPost(1) + hw), :) = ...
            imgRot(round(oPost(1) - hw) : round(oPost(1) + hw),
                   round(oPost(2) - hw) : round(oPost(2) + hw), :);
       end


Avinoam Kalma <avinoam>
Group Member
Sun 11 Mar 2018 10:14:54 PM UTC, comment #4: 

Using: Octave 4.2.1
and:
image *|   2.6.1 | C:\Octave\OCTAVE~1.1\share\octave\packages\image-2.6.1

Bug happens when input image is not square:
pkg load image
im=ones(100,200,3);
rim = imrotate( im, 90, 'nearest', 'crop' );
imshow(rim)


Tis Veugen <tis>
Sun 11 Mar 2018 06:34:11 PM UTC, comment #3: 

I have tried this command, but it worked for me.
Which version of image package and Octave do you use?

Avinoam Kalma <avinoam>
Group Member
Sat 10 Mar 2018 06:29:41 PM UTC, comment #2: 

Adding relevant people

Avinoam Kalma <avinoam>
Group Member
Fri 09 Mar 2018 04:00:21 PM UTC, comment #1: 

Changing category to Octave Forge because imrotate is not a core Octave function, but part of the image package.

Rik <rik5>
Group administrator
Fri 09 Mar 2018 03:08:17 PM UTC, original submission:  

The following command fails:
rotated_image = imrotate( input_image, 90, 'nearest', 'crop' );
For an input RGB image the result is a black image with a 3x3 red dot in the middle.
I checked the failure for several type of input_image's: uint16 or double; 1 channel or 3 channels.
The problem also occurs when rotation angle is -90 degrees.
No problem happens when command is without the 'crop':
rotated_image = imrotate( input_image, 90, 'nearest' );

Probably, there is an optimization for +/-90 degrees that sucks.

Tis Veugen <tis>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by avinoam
  • -email is unavailable- added by avinoam
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by tis (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 group members can vote.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-05-15 carandraug StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Release4.2.1 other
    2018-03-12 avinoam StatusWorks For Me In Progress
        Summary[octave forge] (image) imrotate of +/-90 degrees results in black image when 'crop' [octave forge] (image) imrotate of +/-90 degrees results in black image when 'crop' and RGB image as input
    2018-03-11 avinoam StatusNone Works For Me
    2018-03-10 avinoam Carbon-Copy- Added carandraug
        Carbon-Copy- Added hardy
    2018-03-09 mtmiller SummaryOctave_Forge: imrotate of +/-90 degrees results in black image when 'crop' [octave forge] (image) imrotate of +/-90 degrees results in black image when 'crop'
    2018-03-09 rik5 Carbon-CopyRemoved 72865 -
    2018-03-09 rik5 CategoryOctave Function Octave Package
        Summaryimrotate of +/-90 degrees results in black image when 'crop' Octave_Forge: imrotate of +/-90 degrees results in black image when 'crop'

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code