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

 
 

bug #38087: [octave forge] (image) graycomatrix incompatible with matlab

Submitter:  Carnë Draug <carandraug>
Submitted:  Mon 14 Jan 2013 10:36:25 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Ready For Test Assigned to:  None
Originator Name:  Giorgio Denunzio Open/Closed:  * Open
Release:  * dev Release: 
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 27 May 2025 05:22:11 AM UTC, comment #6: 
Avinoam Kalma <avinoam>
Group Member
Tue 20 May 2025 03:33:34 PM UTC, comment #5: 

I just realized I replied to the wrong bug report. It works fine (tests pass) once I moved the new "graycomatrix" files into installation directory.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 19 May 2025 10:19:14 AM UTC, comment #4: 

Thanks for testing.
isimage is a private function of the Image Package.
Since the function is not in the package yet, isimage is not found.
Please copy it to your working directory, or add its location to the path.

Avinoam Kalma <avinoam>
Group Member
Mon 19 May 2025 10:04:51 AM UTC, comment #3: 


octave:2> pkg load image
octave:3> test graycomatrix
graycomatrix has been re-written. If you want the previous version, run graycomatrix_old
***** test
 # Test basic functionality with default parameters
 img = [1 1 5 6; 3 5 7 1; 5 6 7 8; 8 1 5 1];
 img = double(img) / 8;
 [glcm, scaled_image] = graycomatrix (img);
 expected_si = [2 2 6 7; 4 6 8 2; 6 7 8 8; 8 2 6 2];
 expected_glcm = zeros(8, 8);
 expected_glcm(2, 2) = 1; expected_glcm(2, 6) = 2; expected_glcm(4,6) = 1;
 expected_glcm(6, 2) = 1; expected_glcm(6, 7) = 2; expected_glcm(6, 8) = 1;
 expected_glcm(7, 8) = 1; expected_glcm(8, 2) = 2; expected_glcm(8, 8) = 1;
 assert(isequal(scaled_image, expected_si));
 assert(isequal(glcm, expected_glcm));
!!!!! test failed

'isimage' undefined near line 96, column 13


Perhaps I am doing something wrong. I am using
hg id
1bfe9fac1346 @
of the octave-image.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Tue 29 Apr 2025 04:43:18 AM UTC, comment #2: 

Please review the attached 2 files: graycomatrix.m and _graycomatrix_.cc
This is a MATLAB-compatible version of graycomatrix.

I will rename the current graycomatrix to graycomatrix_old, so that people using it can continue to do so.

(file #57180, file #57181)

Avinoam Kalma <avinoam>
Group Member
Wed 19 Apr 2023 01:48:40 AM UTC, comment #1: 

other than a rename adding the package title to the summary, this report has been idle since it was first filed in 2013, and then it still said things were unverified. 

comparing image package 2.14.0 and Matlab 2023a:

Octave image pkg:

P = graycomatrix(IM, LEVELS, DISTANCES, ANGLES)
     Calculates the gray-level co-occurrence matrix P of a gray-level
     image IM.

     P is a 4-dimensional matrix (histogram).  The value P(I,J,D,THETA)
     is the number of times that gray-level J occurs at a distance D and
     at an angle THETA from gray-level I.


Matlab:

[glcms,SI] = graycomatrix(I,Name,Value)

where the Name options are: GrayLimits (scaling range), NumLevels, Offset (vertical or horizontal distance to comparison neighbor), Symmetric

Marking as Confirmed.

Nicholas Jankowski <nrjank>
Group Member
Mon 14 Jan 2013 10:36:25 PM UTC, original submission:  

This bug was originally reported on the mailing list by Giorgio Denunzio <giorgio.denunzio@unisalento.it> on 2012/10/21




input parameters:
1) matlab wants vectors, one row for each distance/direction couple, and the necessary  information is a vector with x- and y- components, describing the particular relative-position vector(s) we are interested in  ('Offset' parameter) (no idea if I was clear… perhaps it is better to try matlab help :-)  ; octave wants distinct angles (degrees) and distances:


offsets = [0 1; 0 -1;   -1 1; 1 -1;   -1 0; 1 0;   -1 -1; 1 1];
        % matlab
angles = [6 ; 2 ; 5 ; 1 ; 4 ; 0 ; 3 ; 7] * pi/4;   distances = [1];
     % octave



2) matlab implicitly transforms the input-image bit depth ('NumLevels' parameter), while octave needs that you change it beforehand; matlab wants to know the limits of gray level values ('GrayLimits' parameter), octave does not (I do not know if it assumes the whole range of possible values in accordance with the bit depth, or it calculates min and max from the image data (I suppose the former is correct, but I have not checked yet).
Octave just wants to know how many levels are there (not their values). Anyway I still have to totally verify this. The output is also different because octave gives a 4D matrix (numlevels x numlevels x distances x angles, iirc), while matlab gives a 3D matrix:


    numlevels = 16;
    graylimits = [0, 65535];

    % matlab
    theglcm = graycomatrix(I ,'Offset', offsets, 'NumLevels', numlevels ,
'GrayLimits', graylimits);

    % octave
    IOct = uint16(floor(numlevels*(double(I)/graylimits(2))));    %
diminuish bit depth; I supposed graylimits(1) to be zero.
    theglcm = graycomatrix(IOct, numlevels, distances, angles);
    theglcm = squeeze(theglcm);
    %% This works only because I am working with just one
    %% distance value! Now the output is
    %% numlevels x numlevels x angles like in matlab


Carnë Draug <carandraug>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #57180:  __graycomatrix__.cc added by avinoam (5KiB - text/plain)
file #57181:  graycomatrix.m added by avinoam (17KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by avinoam (Updated the item)
  • -email is unavailable- added by avinoam
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by carandraug (Submitted the item)
  • -email is unavailable- added by carandraug (original bug reporter)
  •  

    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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-05-30 nrjank StatusPatch Reviewed Ready For Test
    2025-05-30 nrjank StatusPatch Submitted Patch Reviewed
    2025-04-29 avinoam Attached File- Added _graycomatrix_.cc, #57180
        Attached File- Added graycomatrix.m, #57181
        StatusConfirmed Patch Submitted
        Carbon-Copy- Added hardy
    2023-04-19 nrjank StatusNone Confirmed
        Summary[octave forge] (image) graycomatrix incompatibilities with matlab [octave forge] (image) graycomatrix incompatible with matlab
    2017-08-13 jwe Summaryimage package: graycomatrix incompatibilities with matlab [octave forge] (image) graycomatrix incompatibilities with matlab
    2013-01-14 carandraug Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.15-26b0.
    Corresponding source code