Message Boards Message Boards

Creating image masks interactively

Posted 11 years ago
Take a look at the following example in documentation: Use a marker to specify the holes to be filled



How to make such mask quickly and interactively?

I post here a function that allows to do that.
 MakeMask[i_] :=
  Manipulate[
   Row[{Show[i, PlotRange -> Thread[{{1, 1}, ImageDimensions[i]}]],
     mask = Image[
       Reverse@Transpose@
         SparseArray[# -> 1 & /@ Round[p], ImageDimensions[i]],
       ImageSize -> ImageDimensions[i]]}],
   Button["pasre mask", Print[mask]],
   {{p, {ImageDimensions[i]/2}}, Locator, LocatorAutoCreate -> True,
   Appearance -> Style["+", Red, 40]}, {mask, ControlType -> None}]

POSTED BY: Vitaliy Kaurov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract