Skip to content

Commit

Permalink
matlab/bfGetPlane.m: avoid use of makeDataArray2D when Octave (ome/bi…
Browse files Browse the repository at this point in the history
…o-formats-octave-docker#29)

Octave does not autobox multi-dimensional arrays (Matlab does) so we
can't use makeDataArray2D.  Instead, use makeDataArray to get a 1D
array and reshape it.  This commit partially reverts 3aa468e (see
ome#3301) for Octave only, so the data copy is back but for
Octave only.
  • Loading branch information
carandraug committed Dec 13, 2023
1 parent d566f70 commit 49079c3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions components/formats-bsd/matlab/bfGetPlane.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,20 @@
ip.Results.iPlane - 1, ip.Results.x - 1, ip.Results.y - 1, ...
ip.Results.width, ip.Results.height);

% Convert byte array to MATLAB image
I = javaMethod('makeDataArray2D', 'loci.common.DataTools', plane, ...
bpp, fp, little, ip.Results.height);
% Convert byte array into the appropriate primitive type array which
% Octave and Matlab then autobox into their own array type.
if is_octave()
% Octave will not autobox multi-dimensional arrays, so use
% makeDataArray (returns 1D vector) instead of makeDataArray2D
% See https://github.com/ome/bio-formats-octave-docker/issues/29
I = javaMethod('makeDataArray', 'loci.common.DataTools', plane, ...
bpp, fp, little);
I = reshape(I, [ip.Results.width ip.Results.height]).';
else
I = javaMethod('makeDataArray2D', 'loci.common.DataTools', plane, ...
bpp, fp, little, ip.Results.height);
end

if ~sgn
% Java does not have explicitly unsigned data types;
% hence, we must inform MATLAB when the data is unsigned
Expand Down

0 comments on commit 49079c3

Please sign in to comment.