stckjp
stckjp

Reputation: 117

Selecting mask of irregular shape in matlab

How can I select a mask of irregular shape in an image in Matlab without using the imfreehand but automatically? The background of the image is black and I would like to select the entire image as mask just without the black background (everything without the black background).

Upvotes: 1

Views: 1265

Answers (1)

bla
bla

Reputation: 26069

try this:

threshold=0; % or a different value if needed
mask=image>threshold;

given that the background is truly black, i.e. pixels values are 0, the set threshold to zero. Otherwise, select a value that captures the background (there are ways to do that automatically)

Upvotes: 1

Related Questions