Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Microsoft Paint with Matlab Code

Tags:

image

matlab

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:

1) Open mspaint

2) load image (uint8 matrix) currently saved in workspace into open session

3) when done editing, close mspaint and save new image into workspace (as uint8 matrix)

to implement this, I wish to know:

  • How to load an image from workspace into an open mspaint session.

  • How to save an image from a mspaint session to workspace as uint8 matrix.

  • How to close mspaint - openning is with "system('mspaint')"

Help would be much appriciated.

Thanks, Alon

like image 927
Alon Spinner Avatar asked Feb 13 '26 08:02

Alon Spinner


1 Answers

MSPaint doesn't have an API, however, you can pass a filename to it as a command line argument.

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.

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)

enter image description here

Edit image, then save (Ctrl+s) and exit to return to MATLAB

>> imshow(im);

enter image description here

like image 97
jodag Avatar answered Feb 15 '26 23:02

jodag