trying to make a mask out of this image. How would one go about creating it
my assumption would be to use a threshold where the white perimeter is solid white.
if i get the perimeter to be continuous solid white, how would i tell IM to close/fill the inside?
if someone knows a better approach please let me know thanks
below is the image
https://ibb.co/QYWHkmC
Getting a perimeter and filling in the rest
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Getting a perimeter and filling in the rest
What version of IM, on what platform?
What mask do you want? The central rectangle, or that plus the enclosing black area, or that plus the enclosing white area, or what?
What mask do you want? The central rectangle, or that plus the enclosing black area, or that plus the enclosing white area, or what?
snibgo's IM pages: im.snibgo.com
Re: Getting a perimeter and filling in the rest
i want to mask the whole ipad, starting from the white outer portion. so in the end it should look like in the image below but better (the image still has some black leaking in the white areas
https://ibb.co/M6v2swB
https://ibb.co/M6v2swB
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Getting a perimeter and filling in the rest
Your required output has a wide black margin on the right. I don't know where that has come from. Ignoring that, we can floodfill to isolate the outer black border. That gives a rough edge we can smooth with a blur. The blur has to be large enough to help, but not so large that it damages the curved corners. We do this three times for an almost perfect result. Windows BAT syntax.
Code: Select all
magick ^
i-Pad-threshold.png ^
-strip ^
-fill Red -draw "color 0,0 floodfill" ^
-fill White +opaque red ^
-fill Black +opaque White ^
( +clone -channel RGB -blur 0x10 -threshold 50%% +channel ) ^
-compose Lighten -composite ^
( +clone -channel RGB -blur 0x10 -threshold 50%% +channel ) ^
-compose Lighten -composite ^
( +clone -channel RGB -blur 0x10 -threshold 50%% +channel ) ^
-compose Lighten -composite ^
x.png
snibgo's IM pages: im.snibgo.com