# G'MIC GIMP Plug-in: Use it to "Plot Intensity as Function of (x,y)"?

I’m a user from GimpChat, which first introduced me to G’MIC, via the GIMP plug-in. I’ve managed to use the “Cartesian Transform” (twice!) to distort images to fit desired outlines. However, I was only able to do it with the informed assistance of @garagecoder and @Souphead, who I see are well-known here too.

I am convinced that the G’MIC GIMP plug-in can do what I want; namely,
“create a new image in which the Intensity (I) of a pixel at a specific point has been set programmatically, and mathematically.”

However, I am confused by the Cartesian Tranform’s default paradigm, which appears to rely on “moving pixels at x and y to new locations based on two warping rules.” (This is undoubtedly an flameworthy misstatement of its function, but I am indeed confused, and this benighted interpretation actually did help me get the sought-for end in my examples.)

@Souphead had hinted that setting I(x,y) is probably feasible.

If so, here’s a quest:
"plot I(x,y) = sin(piR)/(piR), R=sqrt(x^2+y^2)"
[the venerable sinc() fcn]

The general goal is to learn the method for setting I(x,y) mathematically.

Let me also say that “to everyone who’s only learned how to use a hammer, every problem looks like a nail,” and I may have reached for Cartesian Transform out of desperation. Polar Transform didn’t look any more tractable, but I suspect the most flexible answer will involve Custom Code.

Well, it’s not a sphere. But it’s not nothin’ either. (It looks sinc-like.)

using this:

I’m sorry. I forgot that the preceding output resulted because I had fed it an image to work on–it did NOT generate the image shown purely from the math.

Here’s the seed image:

Again, my apologies.

If you want to generate an image from `i(x,y) = formula`, then the filter `Colors / User-Defined` is something to investigate

That looks Very (what’s the word for rich vein of ore, dripping with possibilities?) That!

Merci, Professeur.

2 Likes

I present, “The Hemisphere.” Followed by a Question.

``````X=x-w/2;Y=y-h/2;R=sqrt(X^2+Y^2);Rd=w/2;Z=sqrt(Rd^2-R^2);if(R<Rd,Z,0)
``````

This realizes a long-held dream. Thank you for the tools to make it happen, and for the point in the right direction.

Q. For even/ever more complicated expressions, can these be read into the G’MIC plugin from a file? (Don’t anyone trouble themselves to answer if it’s troublesome; I’ll no doubt see the answer in front of me when I open it next. If it’s possible to save/reload Faves to disk, there’s the answer.) Thank you.

Addit: Oh. Also, I wanted to propose these two examples as entries under a subcategory, Heightmaps, under:
https://gmic.eu/gallery/colors.shtml#menu

Yes, that’s possible.
I don’t know what use case you have in mind, but if you want to deal with custom files, maybe you should consider using the command line tool `gmic` rather than the plug-in for GIMP ?

In any case, note that you can still ‘save’ your filter in Faves, this also saves the current filter parameters, so you can save the same filter multiple times, with different parameters (e.g. math expressions).

…maybe you should consider using the command line tool `gmic` rather than the plug-in for GIMP ?

I’m in my element inside GIMP, and am more comfortable with thinking of G’MIC as-a-filter. My “complicated stuff” will likely never run to more than a few lines, and I have been saving, and renaming, multiple Faves inside GIMP, which is all I need.

Since you mention it however, I will say that I have noticed that after I’ve added a new Fave and gone on to edit it with my choices, they are not always saved between G’MIC plug-in launches. I’ve tried to figure out (trying different monkey-see-monkey-do sequences) WHEN the edits are saved: Tabbing to next field?, after hitting Apply?, after OK?, but I’m pretty sure there’s no particular pattern to when edits are saved and when they are, sometimes, not.

I have taken to CLONING a Fave while I’m looking at it (and still copying the formula if it’s complicated for later pasting back) as insurance that my changes are not forgotten.

I guess now that I think about it being able to backup Faves as files is more appealling to me than developing complex code in them.

In fact, I anticipate most of my “codes” of these new heightmaps will be to pull them into GIMP to layer them for more complicated effects.