bugGNU Octave - Bugs: bug #42709, image package: imcrop returns an...

 
 

bug #42709: image package: imcrop returns an image of the incorrect size

Submitter:  None
Submitted:  Tue 08 Jul 2014 04:32:54 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Lutz Andersohn Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * other
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 09 Jul 2014 11:05:23 AM UTC, comment #3: 

This is by design and not a bug. Also required for Matlab compatibility. Basically this is because in RECT ([X_INI Y_INI WIDTH HEIGHT]), X_INI and Y_INI are to be interpreted not as indexing but as coordinates (there is even an option, not yet implemented, to change the coordinate system).

Let's for example assume the simplest example of RECT = [1 1 1 1]. This means that using the standard system, you are not setting the left top coordinate of the cropping rectangle to the top of element (1, 1), but to the center of that rectangle (1.5, 1.5). Then, when you set WIDTH and HEIGHT both to 1, you set the bottom right corner of the rectangle to (2.5, 2.5). Since imcrop() returns any element that is only partially selected, it will return both the first and second rows and columns. Try the following examples:


a = magic (4);
imcrop (a, [1 1 1 1]);
imcrop (a, [1 1 0.5 0.5]);
imcrop (a, [1 1 0.5-eps 0.5-eps])


I guess it could be made more clear on the documentation. Could you please write a nicer explanation for this?

Carnë Draug <carandraug>
Group Member
Wed 09 Jul 2014 02:59:58 AM UTC, comment #2: 

Sorry if I posted this to the wrong list. I have image-2.2.1 installed.

Incidentally, just reported another bug for imcrop for this package.

Anonymous
Tue 08 Jul 2014 04:42:11 PM UTC, comment #1: 

Thanks for your bug report. The imcrop function is part of the image package, not part of Octave 3.8.1. Which version of the image package do you have installed?

Mike Miller <mtmiller>
Group Member
Tue 08 Jul 2014 04:32:54 PM UTC, original submission:  

I call image crop in an image like this:

 CroppedI = imcrop(I, [(CentRowImg)-(CropImSqResSize/2) (CentColImg)-(CropImSqResSize/2) 500 500);

 which is supposed to return a 500x500 size image from the center of the original image.
The image that is returned has 501x501 pixels.

I think the problem is that the imgcrop.m code in line 164 when assigning i_end subtly switches from interpreting the last two parameters as a length to an index. changing the line from

i_end = round ([rect(1)+rect(3) rect(2)+rect(4)]);

to

i_end = round ([rect(1)+rect(3)-1 rect(2)+rect(4)-1]);

should fix the problem. May need some special treatment if the last to parameters are 0 so that nothing is returned.




Anonymous

 

(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 mtmiller (Posted a comment)
  • -email is unavailable- added by None (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-07-09 carandraug StatusNeed Info Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2014-07-08 mtmiller CategoryOctave Function Octave Package
        StatusNone Need Info
        Release3.8.1 other
        Summaryimgcrop in version 3.8.1 returns an image of the incorrect size image package: imcrop returns an image of the incorrect size

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code