Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #228663 > unrolled thread

color border in image, drop everything outside of it

Started byEmanuel Berg <moasenwood@zoho.eu>
First post2020-11-15 00:40 +0100
Last post2020-11-22 10:30 +0100
Articles 20 on this page of 32 — 7 participants

Back to article view | Back to linux.debian.user


Contents

  color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-15 00:40 +0100
    Re: color border in image, drop everything outside of it Michael uplawski <linux-gate@don.blech.e4ward.com> - 2020-11-15 10:00 +0100
      Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-15 10:10 +0100
        Re: color border in image, drop everything outside of it Michael uplawski <linux-gate@don.blech.e4ward.com> - 2020-11-15 11:10 +0100
          Re: color border in image, drop everything outside of it <tomas@tuxteam.de> - 2020-11-15 11:30 +0100
          Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-22 03:30 +0100
    Re: color border in image, drop everything outside of it <tomas@tuxteam.de> - 2020-11-15 10:40 +0100
      Re: color border in image, drop everything outside of it The Wanderer <wanderer@fastmail.fm> - 2020-11-15 11:30 +0100
        Re: color border in image, drop everything outside of it Jeremy Ardley <jeremy@ardley.org> - 2020-11-15 12:00 +0100
        Re: color border in image, drop everything outside of it <tomas@tuxteam.de> - 2020-11-15 12:10 +0100
          Re: color border in image, drop everything outside of it The Wanderer <wanderer@fastmail.fm> - 2020-11-15 12:50 +0100
            Re: color border in image, drop everything outside of it <tomas@tuxteam.de> - 2020-11-15 13:30 +0100
        Re: color border in image, drop everything outside of it Michael uplawski <linux-gate@don.blech.e4ward.com> - 2020-11-15 12:10 +0100
          Re: color border in image, drop everything outside of it Michael uplawski <linux-gate@don.blech.e4ward.com> - 2020-11-15 12:50 +0100
        Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-22 03:20 +0100
      Re: color border in image, drop everything outside of it mick crane <mick.crane@gmail.com> - 2020-11-15 11:40 +0100
      Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-22 03:20 +0100
        Re: color border in image, drop everything outside of it David Wright <deblis@lionunicorn.co.uk> - 2020-11-22 04:40 +0100
          Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-22 05:20 +0100
            Re: color border in image, drop everything outside of it David Wright <deblis@lionunicorn.co.uk> - 2020-11-23 06:20 +0100
              Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-23 06:30 +0100
                Re: color border in image, drop everything outside of it David Wright <deblis@lionunicorn.co.uk> - 2020-11-24 20:50 +0100
                  Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-24 22:40 +0100
                    Re: color border in image, drop everything outside of it <tomas@tuxteam.de> - 2020-11-24 22:50 +0100
                      Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-26 01:30 +0100
                        Re: color border in image, drop everything outside of it <tomas@tuxteam.de> - 2020-11-26 09:50 +0100
                          Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-26 12:30 +0100
                            Re: color border in image, drop everything outside of it <tomas@tuxteam.de> - 2020-11-26 12:40 +0100
                              Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-26 12:50 +0100
                                Re: color border in image, drop everything outside of it <tomas@tuxteam.de> - 2020-11-26 14:10 +0100
        Re: color border in image, drop everything outside of it <tomas@tuxteam.de> - 2020-11-22 10:10 +0100
          Re: color border in image, drop everything outside of it Emanuel Berg <moasenwood@zoho.eu> - 2020-11-22 10:30 +0100

Page 1 of 2  [1] 2  Next page →


#228663 — color border in image, drop everything outside of it

FromEmanuel Berg <moasenwood@zoho.eu>
Date2020-11-15 00:40 +0100
Subjectcolor border in image, drop everything outside of it
Message-ID<Bbdjb-7Ih-7@gated-at.bofh.it>
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?

TIA
            
-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal

[toc] | [next] | [standalone]


#228667

FromMichael uplawski <linux-gate@don.blech.e4ward.com>
Date2020-11-15 10:00 +0100
Message-ID<Bbm38-4sy-5@gated-at.bofh.it>
In reply to#228663
Emanuel Berg:
> 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?
            
-) ImageMagick and their convert-tool
-) The Gimp
-) the list of programs that the next guy will suggest.

-- 
GnuPG rsa4096 2020-09-08 [SC] [expire : 2022-09-08]
      B31591374C4824DE872841D27D857E5045D038F8
sub   rsa4096 2020-09-08 [E] [expire : 2022-09-08]

[toc] | [prev] | [next] | [standalone]


#228669

FromEmanuel Berg <moasenwood@zoho.eu>
Date2020-11-15 10:10 +0100
Message-ID<BbmcN-4L6-3@gated-at.bofh.it>
In reply to#228667
Michael uplawski 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?
>
> -) ImageMagick and their convert-tool

OK, but how?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#228671

FromMichael uplawski <linux-gate@don.blech.e4ward.com>
Date2020-11-15 11:10 +0100
Message-ID<Bbn8R-5k2-5@gated-at.bofh.it>
In reply to#228669
Emanuel Berg:
>> -) ImageMagick and their convert-tool
>
> OK, but how?

That is a mystery which noone ever could resolve. There is pratically no
experience with this tool and no hints have ever been published. I think
the whole thing is utterly useless and that it has never made any sense
to publish this stuff anyway.

Let us just give up and go home, now.

-- 
GnuPG rsa4096 2020-09-08 [SC] [expire : 2022-09-08]
      B31591374C4824DE872841D27D857E5045D038F8
sub   rsa4096 2020-09-08 [E] [expire : 2022-09-08]

[toc] | [prev] | [next] | [standalone]


#228672

From<tomas@tuxteam.de>
Date2020-11-15 11:30 +0100
Message-ID<Bbnsd-5qg-3@gated-at.bofh.it>
In reply to#228671

[Multipart message — attachments visible in raw view] — view raw

On Sun, Nov 15, 2020 at 10:49:34AM +0100, Michael uplawski wrote:

[...]

> Let us just give up and go home, now.

I hope you enjoyed your own sarcasm.

Cheers
 - t

[toc] | [prev] | [next] | [standalone]


#228896

FromEmanuel Berg <moasenwood@zoho.eu>
Date2020-11-22 03:30 +0100
Message-ID<BdNiy-3nS-1@gated-at.bofh.it>
In reply to#228671
Michael uplawski wrote:

> That is a mystery which noone ever could resolve. There is
> pratically no experience with this tool and no hints have ever
> been published. I think the whole thing is utterly useless and
> that it has never made any sense to publish this stuff anyway.

It idea is super-easy, there are three types of colors. it is drop
(d, any color that isn't stop), stop (onee color), and keep (any
color). Drop is outside, keep is inside, stop is ... stop.

So this 

  ddddddddd
  dddsssddd
  ddskkksdd
  ddsssssdd
  ddddssddd

will turn into this

  .........
  ...sss...
  ..skkks..
  ..sssss..
  ....ss...

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#228670

From<tomas@tuxteam.de>
Date2020-11-15 10:40 +0100
Message-ID<BbmFP-4Uy-9@gated-at.bofh.it>
In reply to#228663

[Multipart message — attachments visible in raw view] — view raw

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?

Your request is a bit... unspecific.

Are you (a) after a tool which you use interactively, where you
actually see the image you described above, and where you can
click into that loop to start the operation?

Or is it (b) rather some kind or "batch mode", where you give the
program the image file *plus* the coordinates of that point inside
the loop where to start?

For ease of search, the operation you're describing is usually
called "flood fill". If you are after (a), your friend is The Gimp;
I guess Krita will fill that bill as well. If it's (b), the usual
standard is "mogrify", from the ImageMagick suite. Look at [1] for
the details on flood fill.

Getting warm with the ImageMagick programs takes a bit of practice,
but it's worth it. Come back if you get stuck.

Cheers
[1] https://imagemagick.org/script/command-line-options.php#floodfill
 - t

[toc] | [prev] | [next] | [standalone]


#228673

FromThe Wanderer <wanderer@fastmail.fm>
Date2020-11-15 11:30 +0100
Message-ID<Bbnsd-5qg-7@gated-at.bofh.it>
In reply to#228670

[Multipart message — attachments visible in raw view] — view raw

On 2020-11-15 at 04:38, tomas@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?
> 
> Your request is a bit... unspecific.
> 
> Are you (a) after a tool which you use interactively, where you 
> actually see the image you described above, and where you can click
> into that loop to start the operation?
> 
> Or is it (b) rather some kind or "batch mode", where you give the 
> program the image file *plus* the coordinates of that point inside 
> the loop where to start?
> 
> For ease of search, the operation you're describing is usually called
> "flood fill". If you are after (a), your friend is The Gimp; I guess
> Krita will fill that bill as well. If it's (b), the usual standard is
> "mogrify", from the ImageMagick suite. Look at [1] for the details on
> flood fill.

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.

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.

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.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

[toc] | [prev] | [next] | [standalone]


#228675

FromJeremy Ardley <jeremy@ardley.org>
Date2020-11-15 12:00 +0100
Message-ID<BbnVf-5AD-1@gated-at.bofh.it>
In reply to#228673

[Multipart message — attachments visible in raw view] — view raw

On 15/11/20 6:27 pm, The Wanderer wrote:
> On 2020-11-15 at 04:38, tomas@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?
>> Your request is a bit... unspecific.
>>
>> Are you (a) after a tool which you use interactively, where you
>> actually see the image you described above, and where you can click
>> into that loop to start the operation?
>>
>> Or is it (b) rather some kind or "batch mode", where you give the
>> program the image file *plus* the coordinates of that point inside
>> the loop where to start?
>>
>> For ease of search, the operation you're describing is usually called
>> "flood fill". If you are after (a), your friend is The Gimp; I guess
>> Krita will fill that bill as well. If it's (b), the usual standard is
>> "mogrify", from the ImageMagick suite. Look at [1] for the details on
>> flood fill.
> 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.
>
> 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.
>
> 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.


The requirement seems to be to infill an image inside a bounding line.

This is what happens in postscript rendering when a raster algorithm 
scans a page containing a path defined by some geometry e.g. Bezler 
curve, and every time it crosses the curve on a scan line it changes 
from writing nothing to writing the infill color and back again at the 
next curve intersection

This happens on every character on every page you print on a postscript 
printer. It's a really basic image algorithm.

If it's possible from a script I'm not sure? but it's so simple it's 
very likely


[toc] | [prev] | [next] | [standalone]


#228676

From<tomas@tuxteam.de>
Date2020-11-15 12:10 +0100
Message-ID<Bbo4W-5T9-7@gated-at.bofh.it>
In reply to#228673

[Multipart message — attachments visible in raw view] — view raw

On Sun, Nov 15, 2020 at 05:27:49AM -0500, The Wanderer wrote:
> On 2020-11-15 at 04:38, tomas@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

[toc] | [prev] | [next] | [standalone]


#228679

FromThe Wanderer <wanderer@fastmail.fm>
Date2020-11-15 12:50 +0100
Message-ID<BboHD-65L-1@gated-at.bofh.it>
In reply to#228676

[Multipart message — attachments visible in raw view] — view raw

On 2020-11-15 at 06:06, tomas@tuxteam.de wrote:

> On Sun, Nov 15, 2020 at 05:27:49AM -0500, The Wanderer wrote:
> 
>> On 2020-11-15 at 04:38, tomas@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.

Ah, right, I'd missed the "color that matches" part of the phrase. That
does significantly change the meaning of the definition at that given
link, to something which matches much better with what I'd have expected
the term to mean in the first place.

In that case this seems like an even less suitable match for the request
as I parse it.

>> 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.

I either am badly confused, or don't understand how this relates to the
request at all.

If I'm reading the original request correctly (which I'll admit is by no
means guaranteed), the "single color" used to draw the "loop" - i.e.,
in the example, black - is incidental to the goal; it just defines the
boundary of the region which is to be left unchanged. It may or not even
be important to retain the colored perimeter line in the result; I'd
intuitively expect not, but there could be reasons to do so.

What's outside (or, if you prefer, "on the other side of") the boundary
may well be thousands of different colors, not necessarily in any
pattern which the program can be expected to recognize with relation to
another. The important part of the request is wanting to overwrite all
of that region outside the boundary - regardless of its initial color -
with a single, specified color (for values of "color" that include full
transparency).

I don't see how "flood fill" can fulfill that at all. My best guess
would involve the mention at your given reference link of a "-fuzz"
option which lets the color matching be inexact; that could potentially
make it possible to have a "define the boundary" color which is
sufficiently distinct from every color in the external region that the
fill will be able to match and replace all of the latter but will reject
and neither replace nor propagate past the former, but it seems
improbable that it would be practical to have this distinctness hold
true for every image you might want to process this way.

(Then again it'd also seem impractical to guarantee that whatever color
is chosen for defining the boundary will not occur outside of the
boundary; I think that's why I've been mostly assuming that the literal
drawing of the boundary with a color is just part of an attempt at a
solution to the problem, not an essential part of the problem definition
itself.)

>> 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?

It comes in if the relative location of the specified region compared
against the edges of the canvas is important.

If you stay with just one image (canvas), and replace everything outside
the specified region with a specified color, then the relative position
of the region remains unchanged.

If you copy the region into a new image (canvas), it will be placed
wherever the program decides to put it relative to the edges of that new
canvas, which may or may not wind up having any similarity to its
location on the original canvas.

If that relative positioning was important, then one that doesn't match
it won't suit, so repositioning would be needed. If it wasn't important,
then the new arbitrary positioning would already suit, so no adjustment
would be called for.

Similarly for the size of the original canvas vs. that of the new,
previously-empty image.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

[toc] | [prev] | [next] | [standalone]


#228680

From<tomas@tuxteam.de>
Date2020-11-15 13:30 +0100
Message-ID<Bbpkl-6xP-5@gated-at.bofh.it>
In reply to#228679

[Multipart message — attachments visible in raw view] — view raw

On Sun, Nov 15, 2020 at 06:45:19AM -0500, The Wanderer wrote:

[...]

> Ah, right, I'd missed the "color that matches" part of the phrase. That
> does significantly change the meaning of the definition at that given
> link, to something which matches much better with what I'd have expected
> the term to mean in the first place.
> 
> In that case this seems like an even less suitable match for the request
> as I parse it.
> 
> >> 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.
> 
> I either am badly confused, or don't understand how this relates to the
> request at all.
> 
> If I'm reading the original request correctly (which I'll admit is by no
> means guaranteed), the "single color" used to draw the "loop" - i.e.,
> in the example, black - is incidental to the goal; it just defines the
> boundary of the region which is to be left unchanged. It may or not even
> be important to retain the colored perimeter line in the result; I'd
> intuitively expect not, but there could be reasons to do so.

OK, now I get your objection: the colours "outside the loop" are
many and different. Perhaps the loop's colour is "different enough"
from every other, as determined by the fuzz metrics, then you are
lucky. Perhaps not. Then a more elaborate pipeline is necessary.

> What's outside (or, if you prefer, "on the other side of") the boundary
> may well be thousands of different colors, not necessarily in any
> pattern which the program can be expected to recognize with relation to
> another. The important part of the request is wanting to overwrite all
> of that region outside the boundary - regardless of its initial color -
> with a single, specified color (for values of "color" that include full
> transparency).
> 
> I don't see how "flood fill" can fulfill that at all. My best guess
> would involve the mention at your given reference link of a "-fuzz"
> option which lets the color matching be inexact; that could potentially
> make it possible to have a "define the boundary" color which is
> sufficiently distinct from every color in the external region that the
> fill will be able to match and replace all of the latter but will reject
> and neither replace nor propagate past the former, but it seems
> improbable that it would be practical to have this distinctness hold
> true for every image you might want to process this way.
> 
> (Then again it'd also seem impractical to guarantee that whatever color
> is chosen for defining the boundary will not occur outside of the
> boundary; I think that's why I've been mostly assuming that the literal
> drawing of the boundary with a color is just part of an attempt at a
> solution to the problem, not an essential part of the problem definition
> itself.)

Yep. That's one dificculty. Got it now. OTOH, if your loop isn't
"different enough" in colour from the rest of the image, how do
you differentiate it?

ImageMagick has many other more "intelligent" operations, but to
be able to pick one, the original problem has to be more specified,
I think.

[...]

> It comes in if the relative location of the specified region compared
> against the edges of the canvas is important.
> 
> If you stay with just one image (canvas), and replace everything outside
> the specified region with a specified color, then the relative position
> of the region remains unchanged.

[...]

> Similarly for the size of the original canvas vs. that of the new,
> previously-empty image.

I must have missed the cropping part in the OP's request. But then,
once the main problem is solved, ImageMagick has tools for that.

Another, more precise possibility is to use the "connected component
labeling" [1]: you have to then "know", by image coordinates, for
example, which is the one you want to keep. Basically, a multi-level
flood fill :-)

Cheers

[1] https://imagemagick.org/script/connected-components.php

 - t

[toc] | [prev] | [next] | [standalone]


#228677

FromMichael uplawski <linux-gate@don.blech.e4ward.com>
Date2020-11-15 12:10 +0100
Message-ID<Bbo4W-5T9-9@gated-at.bofh.it>
In reply to#228673
The Wanderer:
> 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.

For the occasional cropping task this is a fine solution.

> I don't know of any tool to
> automate the process to any meaningful degree.

Gimp does a great job offering a tool to select the region which must be
retained. A simple click later, you are done.

Convert is great for automating the procedure, but I venture that the
constraints are too difficult to meet to make it work on a big number of
pictures.

At least I would be interested to be proven wrong.

Michael

-- 
GnuPG rsa4096 2020-09-08 [SC] [expire : 2022-09-08]
      B31591374C4824DE872841D27D857E5045D038F8
sub   rsa4096 2020-09-08 [E] [expire : 2022-09-08]

[toc] | [prev] | [next] | [standalone]


#228678

FromMichael uplawski <linux-gate@don.blech.e4ward.com>
Date2020-11-15 12:50 +0100
Message-ID<BboHD-65L-3@gated-at.bofh.it>
In reply to#228677
I could choose to supersede my previous message but am not sure about
the versatility of your Mail2News vv. procedures.

Michael uplawski:

> Convert is great for automating the procedure, but I venture that the
> constraints are too difficult to meet to make it work on a big number of
> pictures.
>
> At least I would be interested to be proven wrong.

looks like I am proven wrong, as the -trim option to crop exists. Never
mind.

> Michael

-- 
GnuPG rsa4096 2020-09-08 [SC] [expire : 2022-09-08]
      B31591374C4824DE872841D27D857E5045D038F8
sub   rsa4096 2020-09-08 [E] [expire : 2022-09-08]

[toc] | [prev] | [next] | [standalone]


#228894

FromEmanuel Berg <moasenwood@zoho.eu>
Date2020-11-22 03:20 +0100
Message-ID<BdN8R-3kG-3@gated-at.bofh.it>
In reply to#228673
The Wanderer wrote:

> I think you may have misunderstood the request - either that, or
> I did.

I have posted a description how the algorithm would work.
It's really simple.

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#228674

Frommick crane <mick.crane@gmail.com>
Date2020-11-15 11:40 +0100
Message-ID<BbnBU-5tj-7@gated-at.bofh.it>
In reply to#228670
On 2020-11-15 09:38, tomas@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?
> 
> Your request is a bit... unspecific.
> 
> Are you (a) after a tool which you use interactively, where you
> actually see the image you described above, and where you can
> click into that loop to start the operation?
> 
> Or is it (b) rather some kind or "batch mode", where you give the
> program the image file *plus* the coordinates of that point inside
> the loop where to start?
> 
> For ease of search, the operation you're describing is usually
> called "flood fill". If you are after (a), your friend is The Gimp;
> I guess Krita will fill that bill as well. If it's (b), the usual
> standard is "mogrify", from the ImageMagick suite. Look at [1] for
> the details on flood fill.
> 
> Getting warm with the ImageMagick programs takes a bit of practice,
> but it's worth it. Come back if you get stuck.
> 
> Cheers
> [1] https://imagemagick.org/script/command-line-options.php#floodfill
>  - t

I needs to be scripted tho' if want the (x-1, x+1, y-1, y+1)s to be 
wants to be a particular value ?
mick


-- 
Key ID    4BFEBB31

[toc] | [prev] | [next] | [standalone]


#228895

FromEmanuel Berg <moasenwood@zoho.eu>
Date2020-11-22 03:20 +0100
Message-ID<BdN8R-3kG-1@gated-at.bofh.it>
In reply to#228670
tomas 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?
>
> Your request is a bit... unspecific.

I don't know what this is called. Let's say it is called 'cac' for
'cut-around-color'.

so invocation looks like this:

  $ cac gray reaper.png

(we imagine the reaper being dressed in gray, and the sky around
him in dark blue colors)

so what happens is:

start at (0, 0) - this is the top-left pixel, as you know - is
this color gray? answer: no. go to (1, 0) etc until you get to
a grey pixel. at that point, discard all pixels until then.
and don't look any further to the right on that row!

do this for all rows from left to right, top to bottom.

after that, do the same but search top down instead, so after (0,
0), go to (0, 1). discard pixels vertically upon gray. and stop.

do the same from right to left and bottom to top!

Encirclement!

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#228899

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2020-11-22 04:40 +0100
Message-ID<BdOoh-469-3@gated-at.bofh.it>
In reply to#228895
On Sun 22 Nov 2020 at 03:11:21 (+0100), Emanuel Berg wrote:
> tomas 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?
> >
> > Your request is a bit... unspecific.
> 
> I don't know what this is called. Let's say it is called 'cac' for
> 'cut-around-color'.
> 
> so invocation looks like this:
> 
>   $ cac gray reaper.png
> 
> (we imagine the reaper being dressed in gray, and the sky around
> him in dark blue colors)
> 
> so what happens is:
> 
> start at (0, 0) - this is the top-left pixel, as you know - is
> this color gray? answer: no. go to (1, 0) etc until you get to
> a grey pixel. at that point, discard all pixels until then.
> and don't look any further to the right on that row!
> 
> do this for all rows from left to right, top to bottom.
> 
> after that, do the same but search top down instead, so after (0,
> 0), go to (0, 1). discard pixels vertically upon gray. and stop.
> 
> do the same from right to left and bottom to top!
> 
> Encirclement!

How does that work with figures like Ω or ω?

Don't misunderstand me; the figure is drawn as if with a
broad brush, and the closed loop is the entire perimeter
of the brushed area. There are good examples from the
omega wiki page drawn on:
https://en.wikipedia.org/wiki/File:Omega_uc_lc.svg

If the loop is composed of continuous pixels, then you can
scan entire lines, using a semaphore to keep track of
crossing into/out of the loop, as long as their are no
singularities (like there would be, were the Ω serifs
to be drawn as thin as one pixel).

If the loop is a polygon, then you should be calculating
whether each point is inside or outside by calculating
the angles swept out from the point to all the vertices
in turn (finishing back at the first vertex), and seeing
whether you swept out a rotation of 360° (point is
inside) or 0° (outside).

Cheers,
David.

[toc] | [prev] | [next] | [standalone]


#228901

FromEmanuel Berg <moasenwood@zoho.eu>
Date2020-11-22 05:20 +0100
Message-ID<BdP0Z-4yw-1@gated-at.bofh.it>
In reply to#228899
David Wright wrote:

>> Encirclement!
>
> How does that work with figures like Ω or ω?

Well, if the input data doesn't make sense, why worry about the
output data?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#228936

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2020-11-23 06:20 +0100
Message-ID<BecqB-1TO-3@gated-at.bofh.it>
In reply to#228901

[Multipart message — attachments visible in raw view] — view raw

On Sun 22 Nov 2020 at 05:14:25 (+0100), Emanuel Berg wrote:
> David Wright wrote:
> 
> >> Encirclement!
> >
> > How does that work with figures like Ω or ω?
> 
> Well, if the input data doesn't make sense, why worry about the
> output data?

I don't understand what you mean by "sensible" data. Your example

  .........
  ...sss...
  ..skkks..
  ..sssss..
  ....ss...

is a completely convex blob. Are we to understand that as a
constraint? Or are re-entrant shaped loops allowed? What sort
of re-entrants?

I was just pointing out that while your super-easy example works
in a really simple manner, many common shapes, like the attached,
just won't work with that algorithm. Treating each of your scans
as light rays, there are shadow areas that are never scanned,
like the armpits.

Cheers,
David.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | linux.debian.user


csiph-web