copytoImagePlus
is a MATLAB function. Assuming you have communication between ImageJ and MATLAB via ImageJ-MATLAB, copytoImagePlus
allows you to turn a MATLAB array into ImageJ1 ImagePlus
object (a hyperstack).
-
This function is similar to
ijmshow
, but unlikeijmshow
,copytoImagePlus
does not requirenet.imagej.matlab.ImageJMATLABCommands
objectIJM
in base MATLAB Workspace. Therefore,copytoImagePlus
can be used both when you launch an instance of ImageJ from within MATLAB (likeijmshow
) and when you launch an instance of MATLAB from ImageJ. -
copytoImg
andcopytoImgPlus
are bundled with Fiji and work in a similar way but using ImageJ2 API and objects, instead of ImageJ1ImagePlus
object.
imp = copytoImagePlus (I)
imp = copytoImagePlus (I,dimorder)
imp = copytoImagePlus (____,'Param',value)
Optional Parameter/Value pairs
'NewName' char row vector | 'new' (default)
The window title of the new image in ImageJ
'FrameInterval' scalar
Time frame sampling interval in seconds
>> addpath '/Applications/Fiji.app/scripts'
>> ImageJ
>> I = imread('peppers.png') % the size of I is 384 x 512 x 3 in MATLAB
>> imp = copytoImagePlus(I)
>> imp.show();
>> imp = copytoImagePlus(I,'XYC')
>> imp.show();
Open a sample hyperstack image in ImageJ.
>> imp = ij.IJ.openImage("http://imagej.nih.gov/ij/images/Spindly-GFP.zip");
>> imp.show();
>> imp.setZ(3);
Retrieve the array of image data to MATLAB. Note that X and Y axes are flipped over.
>> IJM.getDatasetAs('I');
>> size(I)
ans =
171 196 2 5 51
Data is in double type, although they are better in uint16 type.
>> class(I)
ans =
'double'
>> I16 = uint16(I); % convert to uint16
>> imp2 = copytoImagePlus(I16,'XYCZT') % flip the X and Y axes back
>> imp2.show()
Execute a MATLAB script from Fiji's Macro Editor. File > New > Script and select Language > MATLAB
addpath('scripts')
Miji(false) % add Fiji to Jave class path
I = imread('corn.tif',3);
imp = copytoImagePlus(I) % the function needs to be in MATLAB search path
imp.show();
This is a matlab.unittest.TestCase
subclass and verify the numeric values and dimensions of the ImagePlus
objects in ImageJ opened by copytoImagePlus
.
- 12bit data is not well supported or tested
FrameInterval
may not be properly set, because File Info... does not show the Frame Interval.copytoImg
andcopytoImgPlus
are bundled with Fiji and work in a similar way but using ImageJ2 API and objects.
Kouichi C. Nakamura, Ph.D.
MRC Brain Network Dynamics Unit, Department of Pharmacology, University of Oxford