通过在matlab中拖动鼠标来绘制线条时保留新图像 [英] keep new image when drawing lines by dragging the mouse in matlab

查看:353
本文介绍了通过在matlab中拖动鼠标来绘制线条时保留新图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是matlab GUI的新手。我想通过拖动鼠标来绘制线条。我找到了这个问题,但我想要保存新图像线。如果我运行此行,它将显示相同的图像。

I am new in matlab GUI. I want to drawing lines by dragging the mouse. I found this issue but I want save new image with drawn lines. If i run this line, it will show me the same image.

imshow(im);

如何使用绘制的线条获取新图像,例如显示它?

How can I get new image with drawn lines and for example show it?

推荐答案

您还可以直接在命令提示符中获取图像数据。在图形窗口上绘制所有线条后,可以使用 getframe ,它会拍摄当前帧的快照。在这种情况下,这应该是带有绘制线条的图像。当您调用 getframe 时,这将为您提供一个名为 cdata 的元素的结构。这将为您提供图中所示内容的RGB数组(没有菜单栏......只是图形数据本身)。

You can also grab the image data directly in the Command Prompt. Once you draw all of your lines on your figure window, you can use getframe, which takes a snapshot of the current frame in focus. In this case, this should be your image with the drawn lines. When you call getframe, this will give you a structure with an element called cdata. This will give you an RGB array of what was seen in the figure (without the menu bars... just the figure data itself).

示例:

im = imread('cameraman.tif');
imshow(im);
h = getframe;
out = h.cdata;
figure;
imshow(out); %// Should give you the same image as the figure

这篇关于通过在matlab中拖动鼠标来绘制线条时保留新图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆