Is there a good method for painting over an image in a MATLAB GUI without lag?

5 visualizaciones (últimos 30 días)
I am working on a computer vision project that requires hand-labeled data. To acquire this data, I created a MATLAB GUI that takes as input a raw image, displays the image, allows the user to "paint" over the image where a certain object exists (using click-and-drag type operations), and returns a binary mask, where ones correspond to pixels that the user painted over.
Some technical details...I am using the WindowButtonDownFcn to set the "Selected" property of the figure (so painting starts whenever the user clicks somewhere on the image), the WindowButtonMotionFcn to color pixels during painting, and the WindowButtonUpFcn to stop painting a stroke (by setting the "Selected" property back to "off").
In the WindowButtonMotionFcn (during painting), I get the "CurrentPoint" on the image, add it to an array of previously selected points, then call a rendering function to update the image. The problem is that the image updates take too long, which causes an annoying delay between where I am painting and when it appears on the image.
Does anyone have any experience with this or suggestions on how to speed it up?
Other details that may be helpful...when the user clicks on the image, the "CurrentPoint" is only a single pixel. My images are roughly 600x800 pixels, so I need to incorporate a brush that allows the painted pixels to be visible. Right now, I am using imdilate and strel to enlarge the "paintbrush", but I think this is slowing things down a lot.
Would drawnow or refreshdata help me out here? I can't tell from the documentation.
  2 comentarios
KAE
KAE el 18 de Jul. de 2017
I am assuming the slowdown is when you are running it as a GUI from Matlab, not as a compiled exe. I am noticing the latter is much slower for a similar application.
SURESH BHANOTH
SURESH BHANOTH el 27 de Mayo de 2019
Editada: SURESH BHANOTH el 7 de Jun. de 2019
Mr. Matthew Eicholtz I am working on a computer vision project that requires hand-labeled data. To acquire this data, I created a MATLAB GUI that takes as input a raw image, displays the image, allows the user to "paint" over the image where a certain object exists (using click-and-drag type operations), and returns a binary mask, where ones correspond to pixels that the user painted over.
Some technical details...I am using the WindowButtonDownFcn to set the "Selected" property of the figure (so painting starts whenever the user clicks somewhere on the image), the WindowButtonMotionFcn to color pixels during painting, and the WindowButtonUpFcn to stop painting a stroke (by setting the "Selected" property back to "off"
Mr.Matthew Eicholtz can you send me the code what you have explained above?
thanks in advance

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
Image Analyst el 9 de Ag. de 2014
Editada: Image Analyst el 9 de Ag. de 2014
For what it's worth, Brett has a 4 part series on emulating Photoshop on Steve's blog here: http://blogs.mathworks.com/steve/2012/11/13/image-effects-part-1/. Not sure if it talks about the paintbrush tool though.
  2 comentarios
Matthew Eicholtz
Matthew Eicholtz el 9 de Ag. de 2014
Thanks for the reference. I like Steve's blog, so I'm surprised I hadn't seen that series before. Definitely an interesting read, although it doesn't quite address my issue.
Image Analyst
Image Analyst el 11 de Ag. de 2014
Would you be willing to outline a region instead of "painting" it? If so, use imfreehand(), or roipolyold(). See attached demos.

Iniciar sesión para comentar.


Dima Lisin
Dima Lisin el 11 de Ag. de 2014
Do you need to label arbitrarily shaped regions, or would rectangles be sufficient? In the latter case, please try the Training Image Labeler app in the Computer Vision System Toolbox.

Community Treasure Hunt

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

Start Hunting!

Translated by