File Exchange

image thumbnail

paint on an BW image (updated version)

version (3.17 KB) by Gang Wang
Paint on an BW image on an axis interactively as you did on windows Paint


Updated 15 Mar 2012

View Version History

View License

This function is specially useful for image segmentation software developers who wish to 1)create the ground truth for their algorithm validation or 2) modify the auto-segmentation result.

This is version 2. New features include:
1) Users can paint/erase the mask
2) Can select brush/eraser size
3) export the mask

Run bwpaint_demo:

bottom slider to change slices. left click to paint and right click to erase, please move the mouse slowly otherwise the line will not be continuous.
Click button to export the processed image to A.mat. I save the images into one matrix which is in size of [SIZE_X, SIZE_Y, No._of_Slices x 3];
The images are saved in the following sequence:

R_slice1 (original input image in red channel)
G_slice1 (mask layer in green channel)


If you want to re-process the saved matrix, just reload it into workspace and run


Cite As

Gang Wang (2021). paint on an BW image (updated version) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Chris Loizou

is there anything that i can change on the code to do that?


Thank you! It's what I need!

tong luo

Gang Wang

@sorin hi, sorry for my late reply. please download this updated version. It has the feature you want.


Thank you for the function. It is great.
Please help me to modify the program in the following way:
- I need to have a matrix 128x128 squares (I modified the program according to this fact) and I want to have the drawing in a matrix of zeros and ones (you already did it).
How can I have the cursor exactly of 1x1 size? (taking into account that the whole imaage is 128x128)?
Thank you

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!