Erase color outside of region of interest in image
2 次查看(过去 30 天)
显示 更早的评论
I have a template image that has the outline of a human body, front and back. An individual colors in areas of interest on this template sheet, but a lot of the times they color outside of the body border, I only am interested in analyzing the data that is colored inside of the body border. Does anyone know a way I can erase or ignore the parts colored in outside the body on the template sheet?
0 个评论
回答(1 个)
Walter Roberson
2018-6-1
Presuming that mask is a 2D logical array the same number of rows and columns as your original color image, then:
masked_image = RGBImage .* repmat(mask, [1 1 3]);
The masked image would have 0 in the places to be ignored.
2 个评论
Walter Roberson
2018-6-1
As you have control over the template, it sounds to me as if it would be easy for you to create an additional array which was true for each location in the body outlines and false elsewhere including the white background and the words. If you call that array "mask", and if the image to be processed is the same size then my code applies.
More difficult would be a case where you are taking a picture of what they draw and processing the picture. In such a situation it is likely that the picture would not be exactly aligned with the template and the focal distance is unlikely to be exactly fixed so the resolution would probably not exactly match the template. If we also assume that the outline might be covered over by the colouring, then extracting the inside of the outline might require some kind of image registration or cross-correlation or something like that. If the person colored completely over the edges of the template then the problem could get more difficult.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Feature Detection and Extraction 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!