Inserting zero intensity value in a patch of an digital image.
이전 댓글 표시
My question is how to insert zero intensity value in a patch of an digital image with the help of MATLAB code ? Suppose it is a 16 by 16 patch. Also how to make a curve line or any arbitrary shape having zero intensity value within a digital image ?? Please help me with some easy codes along with an example.
채택된 답변
추가 답변 (1개)
If you want something interactive that works with color images, the MIMT toolbox has a mask editing GUI that supports freehand, polygon, elliptical and rectangular selections. It's awkward, but it works.
inpict=imread('sources/table.jpg');
% launch the GUI
% select the manual selection type (freehand, polygon, etc) from the dropdown
% select the selection mode (replace, add, etc) from the dropdown
% hit 'start manual selection', click on the image to start
% make selection, repeat as necessary
% when done, use the box at the top of the sidebar to export it to the
% workspace (here, i exported it to the variable "mask"
immask('inpict')
This is what the GUI looks like during selection:

% since we're using MIMT, these functions are available
% this uses the mask to change the ROI to a specified color tuple
outpict=replacepixels([0 0 0],inpict,mask);
% view the image
imshow2(outpict,'tools');
This yields the resultant picture:

Of course, if you want something programmatic, this isn't going to help. I'm pretty sure that there are other mask generation GUI tools out there too. EDIT: yeah, regionfill() would be good too.
MIMT is here:
댓글 수: 1
Arghya Pathak
2021년 3월 23일
편집: Arghya Pathak
2021년 3월 23일
카테고리
도움말 센터 및 File Exchange에서 Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!