Is there a good method for painting over an image in a MATLAB GUI without lag?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
KAE
2017-7-18
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
2019-5-27
编辑:SURESH BHANOTH
2019-6-7
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"
thanks in advance
回答(2 个)
Image Analyst
2014-8-9
编辑:Image Analyst
2014-8-9
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 个评论
Image Analyst
2014-8-11
Would you be willing to outline a region instead of "painting" it? If so, use imfreehand(), or roipolyold(). See attached demos.
Dima Lisin
2014-8-11
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!