简体   繁体   English

使用Microsoft Paint与Matlab代码

[英]Using Microsoft Paint with Matlab Code

I need to have a few hundred photos manually inspected and edited. 我需要手动检查和编辑几百张照片。 Certain things need to be blacken out, while others marked in various ways. 某些事情需要变黑,而其他事情则以各种方式标记。

I would like to write a script/GUI that will allow me to do the following: 我想编写一个脚本/ GUI,允许我执行以下操作:

1) Open mspaint 1)打开mspaint

2) load image (uint8 matrix) currently saved in workspace into open session 2)将当前保存在工作空间中的图像(uint8矩阵)加载到打开的会话中

3) when done editing, close mspaint and save new image into workspace (as uint8 matrix) 3)完成编辑后,关闭mspaint并将新图像保存到工作区(如uint8矩阵)

to implement this, I wish to know: 实现这一点,我想知道:

  • How to load an image from workspace into an open mspaint session. 如何将工作空间中的图像加载到打开的mspaint会话中。

  • How to save an image from a mspaint session to workspace as uint8 matrix. 如何将图像从mspaint会话保存为工作空间作为uint8矩阵。

  • How to close mspaint - openning is with "system('mspaint')" 如何关闭mspaint - openning与“system('mspaint')”

Help would be much appriciated. 帮助会很有帮助。

Thanks, Alon 谢谢,Alon

MSPaint doesn't have an API, however, you can pass a filename to it as a command line argument. MSPaint没有API,但是,您可以将文件名作为命令行参数传递给它。

The downside to this approach is that the user is responsible for saving the image back to the same location and exiting MSPaint after editing the image. 此方法的缺点是用户负责将图像保存回相同位置并在编辑图像后退出MSPaint。

function im = edit_in_paint(im)
    temp_filename = [tempname, '.png'];
    imwrite(im, temp_filename);
    system(['mspaint.exe ' temp_filename]);
    im = imread(temp_filename);
    delete(temp_filename)

Example

>> im = imread('rice.png');
>> im = edit_in_paint(im);

(MSPaint opens) (MSPaint打开)

在此输入图像描述

Edit image, then save (Ctrl+s) and exit to return to MATLAB 编辑图像,然后保存(Ctrl + s)并退出以返回MATLAB

>> imshow(im);

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM