It is currently Wed Apr 24, 2024 10:39 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: On the subject of computing a gradient, is there a script?
PostPosted: Thu Apr 20, 2017 2:21 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Or, could there be a script for computing the mathematical gradient for an image of pixels?

A gradient is a vector quantity (having magnitude and direction) which shows, at every point, the direction and intensity of the path of steepest descent (or ascent) from that point.

So a 2D gradient of a 2D image would communicate, at every point, the direction and strength of the quickest way to a lower pixel value. The classic way to do this in physics and other mafth textbooks was to draw a field of tiny arrow of varying directions and lengths. In GIMP, the way 2 independent quantities would appear to be color and brightness.

Alternatively, a "gradient" script could compute the "quickest path to the bottom" from a pre-selected pixel.

I'd be thrilled if someone who knew what I was talking about would take over and speak authoritatively... :^)

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


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: On the subject of computing a gradient, is there a script?
PostPosted: Thu Apr 20, 2017 3:47 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
GMIC's GradientRGB, perhaps?

Attachment:
GradientRGB.png
GradientRGB.png [ 414.59 KiB | Viewed 2474 times ]


Edit: fun effect: GradientRGB, keep Value, invert:

Attachment:
Butterfly-GradientRGB-Value-Inverted.jpg
Butterfly-GradientRGB-Value-Inverted.jpg [ 113.23 KiB | Viewed 2465 times ]

_________________
Image


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Thu Apr 20, 2017 4:09 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Yah, that looks very much like what I had in mind! (Unfortunately, having stretched it so much the first time, it's awful thin now.)

As I've stared at it, I first conclude that the brightness of the pixels on the right indicate the strength of the gradient (slope). The bottom-most white half plane on the left results in black pixels on the right: it must be flat. Colors I'm having a little bit harder time with. If brightness represents strength, colors must represent direction. It makes sense that a circular-ish hole should have gradients in all directions, so all colors should be represented. Sure, and there's a rainbow around the hole. The regularity of the colored tiles in the background threw me, until I guessed that the black and white heightmap on the left represents four angled intersecting planes. If the planes are uniformly sloped to the center, then points anywhere on a plane will have a gradient in the same direction and intensity.

Too many words to say, "I think it works."

Thank you.

Shortly I will check to see if it's helpful to find rivers.

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


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Thu Apr 20, 2017 4:11 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
@ofnuts re: your fun effect

That looks like an excellent way to get a sophisticated pencil sketch! Wow!

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


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Thu Apr 20, 2017 4:31 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Here's the result. The Mississississippi River is not just leapin off the page at me. (I used Filters->G'MIC->Contour->GradientRGB with params 10,0,10.)

To paraphrase the great Inigo Montoya of Princess Bride legend:
"I keep using that word, gradient, but I do not think it means what I think it means.", at least regarding rivers...
Attachment:
USA_GMIC-Contours-GradientRGB_10-0-10.png
USA_GMIC-Contours-GradientRGB_10-0-10.png [ 297.01 KiB | Viewed 2463 times ]

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


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Fri Apr 21, 2017 3:29 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
You may use also the existing filter CrazyWarhol, if you like.
Attachment:
BW, as a Warhol painting, 256 areas.jpg
BW, as a Warhol painting, 256 areas.jpg [ 1.52 MiB | Viewed 2415 times ]

_________________
"Where am I ?"


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Fri Apr 21, 2017 6:37 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
dinasset wrote:
You may use also the existing filter CrazyWarhol, if you like.


Thank you! Have you ever looked at a new filter, and then a to-do/wish/bucket list, and then a calendar, and told yourself, "Oh I, really, don't see myself using this one."? I saw CW, and quickly pulled up all the examples I could from memory and confirmed, "Yeah, pretty far from what I have to be doing."

Without your taking the time to show me, I'd have had no conception it could produce such a work.

(And that goes for a host of other GimpChat contributors too. Thank you all. Lurkers take note. ;^) I pass on what a great professor, James Archer, told me once that "50% of any population is above average." I don't know what he meant either, but half the time I find it motivating...)

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


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Fri Apr 21, 2017 6:52 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Now try to use it on some of your USA pictures...(remember to set no.of colour areas to 256).

_________________
"Where am I ?"


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Fri Apr 21, 2017 7:30 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
dinasset wrote:
Now try to use it on some of your USA pictures...(remember to set no.of colour areas to 256).


" Have you ever looked at a new filter, and then a to-do/wish/bucket list, and then ..."
Oh, alright. :^)

BTW, I remind readers that (most) scripts and plug-ins are text files (and hence readable) and (near the end) they have the information about where the procedure will be found in the GIMP menu system. (Readable files are also editable, so be careful.) In this case the entry is:
menu="menu="<Image>/Diego/Quantize"
putting it in the top-level GIMP menu--and in my mind asserting that the "Diego" menu should be considered of equal importance to "Image," "Colors," "Layers," "Tools," and "Filters" menus. I examined the contents of other filters and re-located it to:
menu="menu="<Image>/Filters/Artistic".
Attachment:
USA_CrazyWarholed.png
USA_CrazyWarholed.png [ 458.09 KiB | Viewed 2386 times ]

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


Last edited by gramp on Fri Apr 21, 2017 7:38 am, edited 1 time in total.

Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Fri Apr 21, 2017 7:36 am  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Do you like the result?

_________________
"Where am I ?"


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Fri Apr 21, 2017 7:45 am  (#11) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
dinasset wrote:
Do you like the result?


Not really, :^(, for my purpose. (I think/I thought) I'm looking for "the quickest way down" from any point, having assumed that's the path a river would take. I can "sort of" guess where "some" will be, but nowhere near the number I think there should be. The fact probably is that rivers mostly flow through areas of elevation changes too small to be represented by 256 brightness levels across the USA. (you think, maybe? :^) )

The results are striking. But I remember that I lost a week when someone handed me a kaleidoscope as a kid... "There was this one pattern..."

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


Last edited by gramp on Fri Apr 21, 2017 7:53 am, edited 1 time in total.

Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Fri Apr 21, 2017 7:49 am  (#12) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
It was just another possible tool to experiment: you did it, sorry it can't help you.

_________________
"Where am I ?"


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Fri Apr 21, 2017 7:55 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
dinasset wrote:
It was just another possible tool to experiment: you did it, sorry it can't help you.


No, no, no, I very much appreciate your help in looking into possibilities. Thank you!

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


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Fri Apr 21, 2017 1:36 pm  (#14) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
gramp wrote:
I pass on what a great professor, James Archer, told me once that "50% of any population is above average." I don't know what he meant either, but half the time I find it motivating...)


50% of the population is above median. A population of one million equal morons and one genius has only one person above average, all the others are (very slightly) below average.

Signed: the math nazi :)

_________________
Image


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Fri Apr 21, 2017 10:49 pm  (#15) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Of course, I've forgotten the details, but the sense I had at the time was that he was not referring to any specific population of 1 million morons+1... :^D

It applies in the correct sense of average I think if it happens to be that intelligence is distributed among the population in a bell-curve fashion.

But your mention of 1 million morons and 1 genius reminds me of Still Yet Another Great Metaphor, this one of 'entropy': "If you add a tablespoon of white wine to a barrel of sewage, you still get sewage, but if you add a tablespoon of sewage to a barrel of white wine, you get sewage."

"Thank you, Math Nazi." (And, if you want to stickle every once in awhile, I figure you gotta right--I just go pull up one of your path scripts and I'm get happy back right quick.)

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


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Sat Apr 22, 2017 3:07 am  (#16) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
gramp wrote:
Of course, I've forgotten the details, but the sense I had at the time was that he was not referring to any specific population of 1 million morons+1... :^D

It applies in the correct sense of average I think if it happens to be that intelligence is distributed among the population in a bell-curve fashion.

But your mention of 1 million morons and 1 genius reminds me of Still Yet Another Great Metaphor, this one of 'entropy': "If you add a tablespoon of white wine to a barrel of sewage, you still get sewage, but if you add a tablespoon of sewage to a barrel of white wine, you get sewage."

"Thank you, Math Nazi." (And, if you want to stickle every once in awhile, I figure you gotta right--I just go pull up one of your path scripts and I'm get happy back right quick.)

Reminds me of a joke:

An engineer, a physicist and a mathematician are in train in the Scottish country side.
  • The engineer looks outside and says: "In Scotland, sheep have a black head"
  • The physicist corrects him: "Sorry but all you can says in that in Scotland there are sheep with black heads"
  • The mathematician then looks out the window and says "Sorry chaps, but the only thing we can really say is that in Scotland there is at least one sheep where at least half the head is black".

_________________
Image


Top
 Post subject: Re: On the subject of computing a gradient, is there a script?
PostPosted: Sat Apr 22, 2017 6:54 am  (#17) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Quote:
Reminds me of a joke:

An engineer, a physicist and a mathematician are in train in the Scottish country side.


Caught me by surprise and I laughed out loud. (I thought that was just an expression...) :geek

_________________
--
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) Palette To Gradient

4

No new posts Attachment(s) GEGL Gradient Map

21

No new posts Attachment(s) Gradient from line

3

No new posts Attachment(s) Gradient from image

2

No new posts Attachment(s) Gradient to Pallette

11



* Login  



Powered by phpBB3 © phpBB Group