Image Saving to Variable in Workspace (NOT imwrite)

12 次查看(过去 30 天)
Hi everyone,
From a computational time point of view, I'm trying to save an image into the workspace instead of creating a figure and grabbing the image. I'm performing a very important task in a very short amount of time 10 sec, and have to perform this task repetitively.
Therefore saving the image using imwrite() is not acceptable due to the computational requirement of having to save the image in memory, and retrieving it. Attached is a code and an image of the figure I am creating as well. Instead of using imshow() in a figure, how can I save the image directly (LLLL).
CODE BEING USED:
figure('Name','Posible Brightness spots for quad-tree analysis');
imshow(sp_possible_quadtree, []);
axis image;
title('Potential blobs for croppping and performing quadtree', 'FontSize', captionFontSize);
LLLL = getimage;
OUTPUT OF THE CODE in a Figure:
then this is the image that is grabbed from the figure and saved.
------------------------------------------------------------------------------------------------------------
Instead of the code above, an ideal solution would be something like this or anything close that doesn't requiere to create an external window (figure handler) to grab it from there.
LLLL = ideal_unknown_function(sp_possible_quadtree, []);
Thanks for your help in advance.
  3 个评论
Stephen23
Stephen23 2020-2-14
imshow shows an array of data in some axes whereas getimage returns an array of data from some axes, so what difference/s do you expect between sp_possible_quadtree and LLLL ?
Daniel Posada
Daniel Posada 2020-2-14
@Subhadeep Koley That is correct I do have sp_possible_quadtree in the workspace, the problem is that by itself it won't show up the features, unless I add the input []*. But what I want to do is to save it without having to go through the imshow process. I don't want to display it, I just want to have it saved in a variable in the workspace.
*(imshow uses [min(I(:)) max(I(:))] as the display range, if [] option is selected)
@Stephen Cobeldick What I want to do is save that image directly without having to use imshow in a figure in order to get the image but still be able to have theb blobs on it as well. If I plot only sp_possible_quadtree the image will be completely black, because it's not showing the features, whereas the LLLL does show them (attached image), but I have to go throught the whole figure process and imshow in order to obtain it. In this case sp_possible_quadtree is a double. where the contents are either 0 for Black, or an integer 1, 2, 3, 4, ... n to differentiate the different blobs. It comes from a bwlabel in order to separate those zones.
sp_possible_quadtree = bwlabel(keeperBlobsImage, 8);

请先登录,再进行评论。

采纳的回答

Subhadeep Koley
Subhadeep Koley 2020-2-14
Use rescale, you can also specify the lower and upper range of scaling.
LLLL = rescale(sp_possible_quadtree);
  2 个评论
Walter Roberson
Walter Roberson 2020-2-14
In older MATLAB releases use mat2gray (which is misleadingly named)
Daniel Posada
Daniel Posada 2020-2-14
tested both methods and they worked perfectly, thank you very much to both of you.

请先登录,再进行评论。

更多回答(1 个)

Stephen23
Stephen23 2020-2-14
编辑:Stephen23 2020-2-14
"In this case sp_possible_quadtree is a double. where the contents are either 0 for Black, or an integer 1, 2, 3, 4, ... n"
LLLL = sp_possible_quadtree ./ n
Images stored as floating point are assumed to be scaled from 0 to 1, so you just need to rescale your image.

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by