Gimp-Forum.net
How to separate an image into multiple layers based on color - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: How to separate an image into multiple layers based on color (/Thread-How-to-separate-an-image-into-multiple-layers-based-on-color)

Pages: 1 2


How to separate an image into multiple layers based on color - jpummill - 04-26-2020

Hi Everyone,

First post.

I would like to know if there is a way to separate an image into multiple layers based on color (or pallet)?

I have created an image with Filter -> Render -> Clouds -> Difference Clouds

[attachment=4252]

Then I apply the Color -> Posterize effect to make the image look like a terrain map

[attachment=4253]

Now I would like to automatically split each color into its own layer (so this image should be about 8 or 9 layers).

Any suggestions would be most appreciated!!!

Thank you,
jpummill


RE: How to separate an image into multiple layers based on color - rich2005 - 04-26-2020

There will be a few ways I am sure. My first thoughts.

(1) Posterizing still leaves a bit of a messy image. Using Colors -> Info -> Colorcube Analysis shows 146 shades.
(2) A better way might be Colors -> Map -> Palette Map  using a suitable palette. I will attach the one I used, might be useful (or not)

[attachment=4254]

(3) I used gimp_gmic_qt see: http://www.gmic.eu to separate those. 
(4) The layers with a couple of them visible.

[attachment=4255]


RE: How to separate an image into multiple layers based on color - Ofnuts - 04-26-2020

If the colors can be separated by their luminosities (or this is a grayscale image) then:

* Add a layer mask to the image, and initialize to Grayscale copy of layer
* Make as many copies of this as you want images
* Use the threshold tool on the mask to keep opaque only the range of values for the image (the threshold tool has two handles and defines a range).

In the example below, since the spectrum of the solid noise is a bit restricted, I used wider ranges at both ends

[attachment=4257]

[attachment=4258]



RE: How to separate an image into multiple layers based on color - dinasset - 04-27-2020

Only a simple comment on Rich's post about "Posterize" in Gimp.
I guess that recent releases of Gimp have a proper handling of Posterizing effect.
After having run Gimp Posterize on an image I found (thru Histogram) that the values are really only n, without messy values around the peaks.
I'm referring to Gimp 2.10.19 Samj's.


RE: How to separate an image into multiple layers based on color - Ofnuts - 04-27-2020

(04-27-2020, 05:47 AM)dinasset Wrote: Only a simple comment on Rich's post about "Posterize" in Gimp.
I guess that recent releases of Gimp have a proper handling of Posterizing effect.
After having run Gimp Posterize on an image I found (thru Histogram) that the values are really only n, without messy values around the peaks.
I'm referring to Gimp 2.10.19 Samj's.

SamJ's somehow versioning is independent of Gimp"s versioning.

However, using my 2.10.14, if I apply Posterize to a I-8 and FP-32 versions of the same grayscale image I get the same histogram with sharp values, However, when I ask for 8 colors I only get 6 spikes...

OTOH the colorcube analysis still reports 199 (FP-32) or 198 (I-8) colors, and if I color-index the I-8 image, I get a colormap with 198 entries...


RE: How to separate an image into multiple layers based on color - rich2005 - 04-27-2020

Used OP's posterized image. Must have been scrambled on download.


RE: How to separate an image into multiple layers based on color - Ofnuts - 04-27-2020

(04-27-2020, 06:42 AM)rich2005 Wrote: Used OP's posterized image. Must have been scrambled on download.

The OP's posterized image is a JPEG. JPEG compression will create new colors.


RE: How to separate an image into multiple layers based on color - rich2005 - 04-27-2020

(04-27-2020, 06:44 AM)Ofnuts Wrote:
(04-27-2020, 06:42 AM)rich2005 Wrote: Used OP's posterized image. Must have been scrambled on download.

The OP's posterized image is a JPEG. JPEG compression will create new colors.

Lets hope that OP is not using that one then. Wink


RE: How to separate an image into multiple layers based on color - jpummill - 04-27-2020

(04-27-2020, 06:46 AM)rich2005 Wrote:
(04-27-2020, 06:44 AM)Ofnuts Wrote:
(04-27-2020, 06:42 AM)rich2005 Wrote: Used OP's posterized image. Must have been scrambled on download.

The OP's posterized image is a JPEG. JPEG compression will create new colors.

Lets hope that OP is not using that one then. Wink

Hey Everyone, I wanted to thank all of you for taking the time to provide input on my question.

Sorry about the image provided being a JPEG.  I didn't think about the ramifications regarding color.  I am still using Gimp 2.8 and my posterize seemed to be working correctly.

I'm looking for a way to automate the process.  I would like to create a python-fu script to create the original image, posterize it, and then split it into separate layers.  I would then like to bump map each layer and create a drop shadow for each layer.

Ultimately, I am trying to create the following type image (and then automate the process).

[attachment=4266]

Thanks again for your useful comments!!!


RE: How to separate an image into multiple layers based on color - Ofnuts - 04-27-2020

(04-27-2020, 03:30 PM)jpummill Wrote:
(04-27-2020, 06:46 AM)rich2005 Wrote:
(04-27-2020, 06:44 AM)Ofnuts Wrote: The OP's posterized image is a JPEG. JPEG compression will create new colors.

Lets hope that OP is not using that one then. Wink

Hey Everyone, I wanted to thank all of you for taking the time to provide input on my question.

Sorry about the image provided being a JPEG.  I didn't think about the ramifications regarding color.  I am still using Gimp 2.8 and my posterize seemed to be working correctly.

I'm looking for a way to automate the process.  I would like to create a python-fu script to create the original image, posterize it, and then split it into separate layers.  I would then like to bump map each layer and create a drop shadow for each layer.

Ultimately, I am trying to create the following type image (and then automate the process).



Thanks again for your useful comments!!!

The technique I explained with thresholded layer masks is inspired by one of my scripts, which is demonstrated here:

http://gimpchat.com/viewtopic.php?f=9&t=9311

The script is here: https://sourceforge.net/projects/gimp-tools/files/scripts/luminosity-tiler-0.1.py/download

Some doc at the bottom of this page: http://gimp-tools.sourceforge.net/tools.shtml

80% of the script can be reused. In fact you just have to remove the pixellation step and the tiles images and use hard-wired values for the thresholds (or your own algorithm/heuristic).  You have to add the drop-shadow (easy to script) and perhaps the smoothing of the curve (but then upscaling noise should do it).