It is currently Thu Jul 04, 2024 2:29 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: [SOLVED] "Intersect" two layers's grayscales? [Lighten-only]
PostPosted: Sun Jun 15, 2014 9:10 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
GIMP Version: 2.8.10
Operating System: Linux
OS Version: Ubuntu 10.04 LTS
GIMP Experience: Intermediate Level



Hi, all you gooduns.

I want to "intersect" one grayscale layer with another one. That is (that is, I think) where the two layers overlap physically and where their grayscales share overlapped values, I want to create a path that follows the intersection of their gray values. [EDIT: see @saulgoode's and @ofnuts' answers below: Lighten-only and Darken-only.]

There's an old problem in drafting to find and draw such an intersection for two cylinders of different diameters crossing at a non-perpendicular angle and with centers offset. A simpler example is lines painted with gradients composed of the same grayscale range: what does the path of their intersection look like. (If they are identical, the path of intersection is a perfect 45-degrees, but non-identical cases are more interesting.)

I was expecting that I'd be able to open a selection tool of some type and just type in the range of gray scales I wanted, and do the same for the other layer, and then work with the two selections to delete some of one or the other.

Sorry. Another Crazy Scheme. As I was writing this, I went back to the threshold tool to create a B&W (Kodalith? anyone? :^) ) boundary, thinking that I could use them--or an intersection or union of them--as Layer Masks, which I rush headlong to confess I have avoided like latter-day whooping cough.

But JUST as I was about to make a breakthrough my brains fell out on the floor.

I suspect this might be easy, but I could be persuaded that it is quite impossible too. Anyway, I know you like--scratch that--you respond politely to conundra sometimes. And I am Conundrum, the Contrarian.

Thank you.

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."


Last edited by gramp on Mon Jun 16, 2014 8:14 am, edited 1 time in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: How can I "intersect" two layers's grayscales?
PostPosted: Sun Jun 15, 2014 11:36 pm  (#2) 
Offline
Administrator
User avatar

Joined: Aug 10, 2012
Posts: 13068
Location: Native to NYC living in Arizona, Gimp 2.8 & 2.10, Win 11 PC.
gramp wrote:
GIMP Version: 2.8.10
Operating System: Linux
OS Version: Ubuntu 10.04 LTS
GIMP Experience: Intermediate Level



Hi, all you gooduns.

I want to "intersect" one grayscale layer with another one. That is (that is, I think) where the two layers overlap physically and where their grayscales share overlapped values, I want to create a path that follows the intersection of their gray values.

There's an old problem in drafting to find and draw such an intersection for two cylinders of different diameters crossing at a non-perpendicular angle and with centers offset. A simpler example is lines painted with gradients composed of the same grayscale range: what does the path of their intersection look like. (If they are identical, the path of intersection is a perfect 45-degrees, but non-identical cases are more interesting.)

I was expecting that I'd be able to open a selection tool of some type and just type in the range of gray scales I wanted, and do the same for the other layer, and then work with the two selections to delete some of one or the other.

Sorry. Another Crazy Scheme. As I was writing this, I went back to the threshold tool to create a B&W (Kodalith? anyone? :^) ) boundary, thinking that I could use them--or an intersection or union of them--as Layer Masks, which I rush headlong to confess I have avoided like latter-day whooping cough.

But JUST as I was about to make a breakthrough my brains fell out on the floor.

I suspect this might be easy, but I could be persuaded that it is quite impossible too. Anyway, I know you like--scratch that--you respond politely to conundra sometimes. And I am Conundrum, the Contrarian.

Thank you.

What was this I just read? :? Whatever it is, you got me with it. :oops:

_________________
Image
"A wise man learns more from a foolish question than a fool can learn from a wise answer"
Image


Top
 Post subject: Re: How can I "intersect" two layers's grayscales?
PostPosted: Sun Jun 15, 2014 11:40 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
If you have two grayscale layers then the "Darken Only" blend mode results in the intersection of those two layers (and "Lighten Only" produces their union).

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: How can I "intersect" two layers's grayscales?
PostPosted: Mon Jun 16, 2014 2:36 am  (#4) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4003
Location: Canada
in your 45 degrees angle simple example, do you mean like this?
for example, we have 2 layers named "horizontal" and "vertical" which are gray scales gradient perpendicular to each other.
Image
set "horizontal" (top) layer to difference mode
Image
create "new from visible", this creates a layer named "visible"
Image
select "horizontal" layer, alpha to select
Image
select "visible" layer, apply a really low threshold
Image
and you'll get your 45 degrees white appearing.
Would these steps work for you?

_________________
TinT


Top
 Post subject: Re: How can I "intersect" two layers's grayscales?
PostPosted: Mon Jun 16, 2014 5:50 am  (#5) 
Offline
Script Coder
User avatar

Joined: Nov 06, 2012
Posts: 239
Location: Italy
I think a possible solution could be to reproduce the contents of both the layers on two channels that eventually you will able to easily combine by intersection.

Once you have picked out the first of the two layers, you have to create a layer mask having the same appearance of the related layer by checking the "Grayscale copy of layer" radio button in the "Add Layer mask" dialog. Then you can run the "Mask to Selection" command and save the resulting selection to a new channel by means of the "Save to Channel" command.
Having done this on the first layer, repeat the same operations for the second layer, remove the masks from the layers if necessary, select the first of the two channels obtained and right-click on "Channel to Selection", thus select the second channel and right-click on "Intersect with Selection".

Following this procedure, you will finally have a selection which features an exact intersection of the two original layers in terms of shades of gray. As obvious, the last step will consist in turning this selection to a path, either directly or after possibly saving the selection to a third new channel.

_________________
Gino D's GIMP scripts: https://sites.google.com/site/ginodonig/gimp-scripts


Top
 Post subject: Re: How can I "intersect" two layers's grayscales?
PostPosted: Mon Jun 16, 2014 7:19 am  (#6) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
I agree with Saulgoode, look at "Darken only"/"Lighten only" modes:

Attachment:
Pipes.png
Pipes.png [ 90.64 KiB | Viewed 5825 times ]

_________________
Image


Top
 Post subject: Re: How can I "intersect" two layers's grayscales?
PostPosted: Mon Jun 16, 2014 7:58 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
First of all, thank you, all, for your replies.

Second of all, LOOK AT THE POSTING TIMES! I posted at 10:10--exactly 40 min. after my bedtime... but all of you stayed up late to offer advice.

@saulgoode In my calculated thoroughness, I "pressed all the buttons" in Layer Properties trying to find one that looked right. But as I write this, it occurs to me I should maybe try that again with the masks. I accept what you wrote about intersection and union; I only need now to think about the implications of that to form an approach. (Possibly using those operations on thresholded layers...)

@trandoductin I had in mind a picture frame molding; same as your example, but with the gradient directions 90 degrees to yours. It will take me a LOT longer to cook up a step-by-step half as good as your post however... In such an example, a successful intersection will allow the creation of the "mitered" corner for the two components. What is it then that is my goal? It is the completion of this sentence: "The miter of a picture frame represents the set of locations of two images where the pixel values are equal." Maybe.

@Gino D I have read through your post multiple times. Each time I found myself "postponing" thinking about the implications of "channel" and getting, somewhat, the rest of it. But I start panicking when as I approach the end--when I realize I'm running out of stuff to read and I still don't quite understand--and then I hit the last word. And my brains fall out on the floor just like with Masks. I had actually experimented with doing something like this--but with much less insight--by making a threshold of one layer and using it as a mask on the other layer. But masks, it appears, seem to be about transparency (and therein might lie a tale). I'll read up on Channels and revisit your advice.

@Wallace THAT was the "Third of all" point of the post: "Get Wallace!" ;^) and I'm afraid my clarification whacked you again... If you've read this far, you have my deeper apologies.

@ofnuts Et tu? up early. Glad I hit "Preview" before submitting. That's exactly the effect wanted. I remember trying it. I remember it didn't produce the effect. I remember I've had false memories before. (@saulgoode So much for "blahblah...implications for planning an approach...blahblah.")

Thanks all, I'll see what transpires. (@Gino D I still look at Channels because I aspires to be a Advanced user one day.)

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."


Top
 Post subject: Re: How can I "intersect" two layers's grayscales?
PostPosted: Mon Jun 16, 2014 8:04 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
@ofnuts It works for me too: Lighten-only in my case. (Darken-only then perhaps in other cases.) I'll fix my first post to cut to the chase.

@saulgoode I must not have pressed every button; I must've got distracted by something shiny.

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."


Top
 Post subject: Re: How can I "intersect" two layers's grayscales?
PostPosted: Mon Jun 16, 2014 8:12 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Here's the result (This is supposed to be a representation of a RR rail disappearing into a picture frame.)

Attachment:
Left.png
Left.png [ 1.12 KiB | Viewed 5814 times ]
Attachment:
Right.png
Right.png [ 1.02 KiB | Viewed 5814 times ]


Attachment:
Intersection.png
Intersection.png [ 3.54 KiB | Viewed 5814 times ]

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."


Top
 Post subject: Re: How can I "intersect" two layers's grayscales?
PostPosted: Mon Jun 16, 2014 10:07 am  (#10) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
gramp wrote:
First of all, thank you, all, for your replies.

Second of all, LOOK AT THE POSTING TIMES! I posted at 10:10--exactly 40 min. after my bedtime... but all of you stayed up late to offer advice.


We don't all live in the same time zone, or even on the same continent... My post above was at 2pm in my local time...

_________________
Image


Top
 Post subject: Re: How can I "intersect" two layers's grayscales?
PostPosted: Mon Jun 16, 2014 10:26 am  (#11) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Gino D wrote:
Once you have picked out the first of the two layers, you have to create a layer mask having the same appearance of the related layer by checking the "Grayscale copy of layer" radio button in the "Add Layer mask" dialog. Then you can run the "Mask to Selection" command and save the resulting selection to a new channel by means of the "Save to Channel" command.

One should be able to drag-n-drop a layer's thumbnail preview from the Layers dialog to the Channels dialog, thus creating the new channel whilst avoiding the intermediate step of creating a layermask.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: [SOLVED] "Intersect" two layers's grayscales? [Lighten-only]
PostPosted: Mon Jun 16, 2014 11:29 am  (#12) 
Offline
GimpChat Member
User avatar

Joined: Feb 14, 2012
Posts: 426
If you have two greyscale layers and one is set to darken only then the darker values will show where they intersect. If you want to make a "selection" of the difference then you can just do a layer from visible, and then take the darken only layer and put it above the new layer and set the layer mode to grain extract. This will give you a greyscale visualization of the difference. Then just do another layer new from visible and run the threshold on it which will result in a black and white representation of the difference which you can then make a selection out of and then even a path from the selection. I do this along with colorize to create color height maps sometimes.


Top
 Post subject: Re: [SOLVED] "Intersect" 2 layers' grayscales? [Lighten-only]
PostPosted: Tue Oct 11, 2022 10:06 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
A note of caution. It is now 2022, I am using GIMP 2.10 in Ubuntu 20.04.

I have a grayscale image and two grayscale layers of gradients, in a group, I'd like to intersect.

I set both layers to Legacy and the group, and then the one above to Lighten-only (the lower one is Normal, as is the group).

The results were not the intersection I expected, and after a couple of hours of trying everything, I finally made a new project with just those two layers, and no group. I got the same weird result until I thought to add a black layer at the bottom. Poof-Poff! it worked, which is to say the expected result appeared.

I tried adding a Black layer to the bottom in the original, but until I added a Black layer to the bottom of the group containing the two gradients of interest, I got the same weird result.

I recall having trouble with my vague understanding of group interactions in the past. I use them for "administrative/organizational" purposes, but my opinion is that must affect how layers interact because they too have modes.

Cheers, all!

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."


Top
 Post subject: Re: [SOLVED] "Intersect" two layers's grayscales? [Lighten-only]
PostPosted: Wed Oct 12, 2022 3:05 am  (#14) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
Why are you using "Legacy"?

_________________
Image


Top
 Post subject: Re: [SOLVED] "Intersect" two layers's grayscales? [Lighten-only]
PostPosted: Wed Oct 12, 2022 5:35 am  (#15) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
@ofnuts "Why are you using Legacy?"

Short answer: Because I find Legacy effects predictable. (And because I've never taken time to understand the difference.)

Longer answer: When my workflow became unpredictable because of an upgrade, I posted what had happened and was informed that I could get back to what I was used to by making the Layers Legacy. [...which meant doing odd things with 8-bit GIMP to get clever results which 32-bit GIMP can likely now do straightforwardly]

As I recall, the motivation was a problem in this very area of "stacking layers" to get certain effects.

Like all habits, and I don't know if this one is bad per se, it is almost automatic for me to Create a Layer and Make it Legacy. And like some other old people who come to mind, I tend to prefer sticking to old habits to spending unknown amounts of time learning something new. (I hasten to add that I have often paid dearly for that one too: wasting more time avoiding learning than it would have taken to learn it. On the flip side, I have also beaten my head against a wall--C++--to learn something that remained just outside my grasp than it would have taken to just do it the way I knew. That I suspect is a common trait.)

[I just checked and found that there's no discernible difference between the modes on the stacking-for-blending I'm trying to do. At your instigation, I'll spend some of my precious time to look into the differences to give a bettter answer, or just drop the habit. Counting up the second or two it takes me to enable Legacy, I've probably got a couple of years invested in that practice.]

[Update: on my very first search for "Legacy Default difference" I found this "smoking gun". ;)]
[And wouldn't you know, pasting the weblink in here, I found the user interface for "Web address" quite different from what I'm used to from other sites. Another choice: investigate how GimpChat wants me to format it, or paste it raw "because the probability I'll need to do it again--a lot--is low?"]
[Update: I found the circled question mark icon to the upper right, taking me directly to the formatting guide, so I'm fixing the weblinks.]
[Update: I posted results of my very second search to this new topic, showing off my now compleat mastery of Web Address.]

Cheers!

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."


Top
 Post subject: Re: [SOLVED] "Intersect" two layers's grayscales? [Lighten-only]
PostPosted: Wed Oct 12, 2022 6:38 am  (#16) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
Your "smoking gun" is a different problem. You tried to do an arithmetic addition and Gimp isn't about linear arithmetic but about visual results that require logarithmic corrections (aka "perceptual")(for instance the "perceptual" 50% gray (the tone of a checkerboard seen from far away) is (185,185,185) and not (127,127;127) .

In Gimp 2.8 and previous all computations were done directly on perceptual, which produces false results, a well know example being a red-green gradient, which if done directly with perceptual values goes through brown, while it should go through orange. Since Gimp 2.10, if values are kept as "perceptual" values (at least in 8-bit/channel images) the computations are done on linear data (so there is conversion before and after). This applies also to blend modes. Try this:

- Create green layer
- Add a red layer
- On the red layer, add black white layer mask (make sure the "blend color space" is "linear RGB" in the blend tool). If the Red layer is in Default/Normal, you get a nice red -> orange -> green gradient:

Attachment:
ksnip_20221012-132948.png
ksnip_20221012-132948.png [ 42.99 KiB | Viewed 679 times ]


- If you set the red layer to Legacy/Normal your get a red -> dirty brown -> green gradient:

Attachment:
ksnip_20221012-133001.png
ksnip_20221012-133001.png [ 36.29 KiB | Viewed 679 times ]


In 2.10, unless you have a very good reason not to (and if you find one it will usually not be, it will just be that you are trying to solve the wrong problem), you should use the default "linear" modes.

_________________
Image


Top
 Post subject: Re: [SOLVED] "Intersect" two layers's grayscales? [Lighten-only]
PostPosted: Wed Oct 12, 2022 6:50 am  (#17) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Thanks Of, for taking extra time to provide that illumination.

Your quote:
ofnuts wrote:
In 2.10, unless you have a very good reason not to (and if you find one it will usually not be, it will just be that you are trying to solve the wrong problem), you should use the default "linear" modes.

reminded me of my tutelage under one of those classic "Unix geeks" who could've been the prototype for same in Scott Adams Dilbert saga. One of the, legion, quotes he uttered was this advice about how to troubleshoot a computer network: "Just remember, even when you've eliminated everything else as the source of the problem and only the network is left, it's never the network."

So my Action Item is: on my very next project, I'm going to start off and stick with "linear modes." Or the One Right After the Next One. Probably. (Actually, I'm mailing myself the link to your last post.)

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."


Top
Post new topic Reply to topic  [ 17 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) math tools like union and intersect?

7

No new posts Attachment(s) Experiment with a Lighten-only Height/Depth/Bumpmap Brush

2

No new posts Layers

2

No new posts Help with masks and layers please!

3

No new posts Attachment(s) Wrap all layers

4



* Login  



Powered by phpBB3 © phpBB Group