On Sun, Nov 15, 2020 at 05:27:49AM -0500, The Wanderer wrote: > On 2020-11-15 at 04:38, to...@tuxteam.de wrote: > > > On Sun, Nov 15, 2020 at 12:31:22AM +0100, Emanuel Berg wrote: > > > >> Hello, is there a tool/command/script anywhere that can overwrite > >> with a single color (or make transparent) every pixel to the left, > >> above, right, and below a certain other color? > >> > >> e.g., if one draws a loop of black, tell the program black is the > >> border, the result would be only what is within the loop?
[...] > I think you may have misunderstood the request - either that, or I did. > > From the description of "flood fill", what it does is replace everything > within a certain distance of a specified point with a specified color. > That maps to "fill a specified region with a specified color", if the > region is radius-based. No, no. Unless you mean "distance in colour space". Look again at the given ref, [0]. Flood starts at a pixel, considers every neighbour [1] having the same colour [2] and repeats that process for those selected neighbours, until all possibilities are exhausted. Optimising that is left as an exercise to the reader, as they say :-) It's a "classic" in bitmap and pixmap graphics. > What I understand the request to be is for a way to replace everything > *outside of* a specified region with a specified color, where the region > is *not* necessarily radius-based but may potentially be freeform. Yes, but then, one person's "inside" is the other person's "outside". You just have to choose judiciously your start point (aka "seed"). And, of course, make sure the region thusly defined is connected. If you think your "border" (Emanuel's "black loop") extends so far as to multiply touch your image frame (so as to yield several disconnected regions), you better extend the image a bit in every direction somehow. But wait! that's what ImageMagick already does... magically, with its VirtualPixels [3], the default being 'edge', so just what we need. The (flat) world is a sphere, after all (at least in the context of flood fill, that is). > If I needed to do that, what I'd probably wind up doing is to select the > desired region, copy it, paste it into an empty image, and adjust its > position and the size of the image to suit. I don't know of any tool to > automate the process to any meaningful degree. Hm. I can't follow that last one. Perhaps I haven't understood anything, after all (not unheard of, mind you :). Where does the (re-) positioning come in? Cheers [0] https://imagemagick.org/script/command-line-options.php#floodfill [1] For some definition of neighbour [2] "Same colour" is often too restrictive, so this is usually relaxed to "similar enough": that's the -fuzz parameter in [0] [3] https://imagemagick.org/script/architecture.php#virtual-pixels - t
signature.asc
Description: Digital signature