Note that there are some explanatory texts on larger screens.

plurals
  1. POimagemagick get a co-ordinate for pixel with most common color
    primarykey
    data
    text
    <p><br> In short, I want to find out co-ordinate of a pixel with predominant color.</p> <p>To be specific, I want to achieve the following:</p> <ol> <li><p>Find predominant color. By predominant, I mean a color that majority of the pixels in an image have (I have achieved it using histogram)<br></p></li> <li><p>After getting this color (in my case its black), I want to find a pixel that is black and its surrounded by only black pixels. Basically, the center of most concentrated area of black.</p></li> </ol> <p>Till now, I could only get the predominant color.</p> <pre><code>convert src.png -format %c histogram:info: &gt; x.txt cat x.txt | awk '{print $1}' | sed 's/://g' &gt; x1.txt h=$(sort -n x1.txt | tail -1) cat x.txt | grep "$h" rm -rf x.txt </code></pre> <p>Result:</p> <pre><code> 169211: ( 0, 0, 0,255) #000000 black </code></pre> <p>Now, I can also get all the co-ordinates for black<br></p> <pre><code>convert src.png txt: | grep black 469,799: ( 0, 0, 0,255) #000000 black 470,799: ( 0, 0, 0,255) #000000 black 471,799: ( 0, 0, 0,255) #000000 black 472,799: ( 0, 0, 0,255) #000000 black 473,799: ( 0, 0, 0,255) #000000 black 474,799: ( 0, 0, 0,255) #000000 black 475,799: ( 0, 0, 0,255) #000000 black 476,799: ( 0, 0, 0,255) #000000 black 477,799: ( 0, 0, 0,255) #000000 black 478,799: ( 0, 0, 0,255) #000000 black ... </code></pre> <p>But I need a random co-ordinate of a black pixel that is located at a place where there is a only black pixels around it...<br></p> <p>I am using Linux and Imagemagick version 6.6.5</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload