raylight
raylight

Reputation: 727

Is there any way of creating an equal value area by color on ImageMagick?

Let's say I have the following image:

enter image description here

I know that using Global Mapper I can create polygons around an area with a specific color. On the following example it's creating an area around the grey area:

enter image description here

This feature is called Setup equal value area creation. I'd like to do something similar with ImageMagick, is it possible? Can I draw areas according to the colors that I have in an image with ImageMagick (or get the polygon's coordinates just so I can draw them on the original image later)?

Upvotes: 0

Views: 73

Answers (2)

fmw42
fmw42

Reputation: 53154

I am not sure what you want, but perhaps the following in ImageMagick. Suppose you measure the color at a location (150,60) in the large gray rectangle and want to draw another rectangle with the same color. Using ImageMagick 7,

Input:

enter image description here

magick img.png -set option:color "%[pixel:u.p{150,60}]" -fill "%[color]" -draw "rectangle 40,30 80,50" img_rect.png

enter image description here

Upvotes: 2

Mark Setchell
Mark Setchell

Reputation: 207670

Your image is blurry, with all the colours really difficult to differentiate and it makes my eyes hurt. I also have no idea which part of it you are really interested in and what is just poor cropping/selection. So, I chose what I think are the things you might be interested in and separated out their colours so they are distinguishable from one another and got this:

magick 0N9iv.png -alpha off -fuzz 10% -fill black -opaque "rgb(169,226,140)" -fill gray -opaque "rgb(212,208,204)" -fill white -opaque white \( +clone -colorspace gray -edge 1 -write edges.png \) -compose copyred   -composite result.png

enter image description here

Everything up to the opening parenthesis is just separating your objects. The part inside the parentheses makes white outlines and saves them for checking in a file called edges.png. The final part just colourises the edges and adds them back into the original.

I, or somebody else might be able to do better if you are clearer about what you are actually trying to do and what aspects of the image are important to you.

Upvotes: 2

Related Questions