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!