How do you load in an image/image stack in MIJ from the matlab workspace?

3 次查看(过去 30 天)
Hi! I am using MIJ to use imagj/fiji inside matlab. But I can only see the option to load a file from the computer hard disk. I however want to load a file from inside my matlab workspace. Is there any way to do this?

回答(1 个)

Karanjot
Karanjot 2023-9-13
Hi Kevin,
The workspace contains ‘variables’ that you create or import into MATLAB from data files or other programs. On ‘importing’ a file to the MATLAB workspace, it implies that MATLAB reads the image from the file and returns a 3-dimensional array.
imageVar = imread('image.jpg');
Note that ‘imageVar’ in the workspace is not an image but an array.
To learn more about this, you can refer to the below documentation:
To load a file from inside the MATLAB workspace, you may preview the image using the below command.
image(imageVar)
Click on the save icon on the toolstrip of the preview window to save it as a file on your computer. Now, you can load the image file from your computer.
I hope this helps!
Regards,
Karanjot Singh
  1 个评论
DGM
DGM 2023-9-13
编辑:DGM 2023-9-13
What does this have to do with the question? OP asked how to access data from the MATLAB workspace via MIJ. This answer contains the following information:
  • an unnecessary explanation of what the workspace is
  • an explanation of how to "load a file" by displaying an image in a figure and then saving the figure.
Even if you're suggesting that OP accomplish a workaround by saving images to disk and then using the ability of MIJ to access files on disk, then saving screenshots of figures is not an acceptable way to do that.
inpict = imread('peppers.png'); % an image
image(inpict) % literally your suggestion
saveas(gcf,'garbage.png') % take a screenshot
trash = imread('garbage.png'); % a screenshot is not the same thing
imshow(trash)
% it's not even the same size or aspect ratio
size(inpict) % the original size
ans = 1×3
384 512 3
size(trash) % the size of the screenshot
ans = 1×3
656 874 3
If you want to save images, use imwrite() or whatever the appropriate image writing utility is. That said, I don't know that this workaround is even necessary or appropriate. I don't have or use Fiji, ImageJ, or MIJ. That's why I never answered this question.
If OP wanted to ask a chatbot or magic 8 ball for a collage of words qualified merely by their contrived ability to sound marginally human, they would have wasted their own time doing so. They asked a forum because they wanted to get a response from an actual person who was familiar with the things they were using and had an actual informed answer.
If you don't know enough about the subject to identify the correctness of the answer, don't go asking an AI garbage generator for answers. If you don't have an answer to the question, you don't have an answer to the question.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by