Giving specific values to pixels in some selected region

折月煮酒 提交于 2020-01-11 12:59:11

问题


I'm trying to do the following in MATLAB:

  • Select some region of interest
  • Give the pixels in that region the value 1 for instance

I'm not sure, would imfreehand be a starting point here for selecting the region of interest. What then?

How can this be done in MATLAB?

Thanks.


回答1:


Here is a short sample. Since you mentioned imfreehand, I included that but depending on what type of ROI you want to create, impoly or imrect may do a better job:

img = im2double(imread('cameraman.tif'));
imshow(img);
roi = imfreehand;
img2 = img;
img2(roi.createMask) = 1;
imshow(img2);


来源:https://stackoverflow.com/questions/18363617/giving-specific-values-to-pixels-in-some-selected-region

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!