Switch to full style
Post a reply

[SOLVED] G'MIC as Pixel Intensity Calculator/Heightmap Generator???

Tue Sep 17, 2019 8:11 am

I've been on a quest for some years to (mis? ab?)use GIMP for sculpting real objects by creating suitable heightmaps/depthmaps. (Shades of gray represent regions of unique elevation, and black and white represent the extremes.)

I have twice used G'MIC to "calculate" how to stretch an image to make it fit a desired profile, once here, and most recently to do this:
GIMP_AfrBEFAFT.gif
GIMP_AfrBEFAFT.gif (175.17 KiB) Viewed 8988 times

It took me 3 days of alternating Newtonian and Edisonian approaches (pondering/experimenting), and in the end, when I got it to work for stretching one side, I gave in to my inner Edison and flipped the image to do the other side...

I can sense the Power of the G'MIC's Maths pulsating behind GIMP's window, even when I merely use GIMP as an image viewer (:horrors:), so I'm completely persuaded that it can do what I want it to do--if I can figure out what, and where, to ask it.

My Latest Quest, since I seem completely unable to generate a grayscale gradient (using the conventional tools of radial gradient followed by colors->curves) to precisely represent the heightmap of a (hemi)sphere, I would like to use G'MIC to generate those grayscale values, mathematically perfectly.

That is my quest. As usual, I could use some help finding where I left my lance and shield, and getting up on my charger, wherever I left it. I just wanted you to know if anyone asked where I'd be: questing.

To Be Clear:
I want to use a G'MIC tool to generate a grayscale image[1] which, when loaded into a CAM program which can read heightmaps, will result in a Perfect half-sphere when machined. Unless I forget.

[1] "Conjuring" in G'MIC-speak.

Re: G'MIC as Graphic Calculator/Solid-model Generator

Tue Sep 17, 2019 10:13 am

Actually I had forgotten a potential Ofnuts' ProfileMap, followed by WrapMap, solution[1]:
http://gimpchat.com/viewtopic.php?f=9&t ... uts#p15543

which gives pretty good results, although still relying on a user's drawing rather than deriving from a specific mathematical formula:
ProfileMap_WrapMap.png
ProfileMap_WrapMap.png (82.95 KiB) Viewed 8971 times



[1] One of those gifts which keeps on giving.

Re: G'MIC as Graphic Calculator/Solid-model Generator

Tue Sep 17, 2019 1:15 pm

On the subject of "graphic calculator", I'd like to scan an image consisting of an image inside a geometric shape on a transparent background (say, circle), and copy it line by line to another prepared image with a different shape (say, diamond), scaling lines of non-transparent pixels from the original to fit the space permitted for corresponding lines in the target.

It just feels like the sort of thing G'MIC would do as a matter of routine. (The previous "lunar" problem could then be seen as "re-writing a rectangle into a circle".)

Algorithmically:
* open both images
* find first and last rows and columns for non-transparent pixels in both images
* proceed to "first" row of both images, read left-and-right to determine endpoints
* "copy" first row from source to target, scaling as necessary
* leave remainder of pixels in the target row transparent
* do remaining rows

Re: G'MIC as Graphic Calculator/Solid-model Generator

Wed Sep 18, 2019 4:37 am

Not sure what you want to achieve but it's <quite> easy to map images to spheres and other shapes:
http://gimpchat.com/viewtopic.php?f=25&t=16421&p=227043&hilit=miniplanets#p227043

Re: G'MIC as Graphic Calculator/Solid-model Generator

Wed Sep 18, 2019 7:02 am

Thanks, Tas. I've had no interaction with MathMap yet, but see that the much-vaunted GIMP registry is dead. (I have indications that I may have installed it in the past, so maybe...) EDIT: But then, there's the Keeper of the Lost Plugins.

Your "miniplanets" remind me that there are many ways to "map" the contents of one shape into/onto another.

In my application, I want merely[1] to "copy across", line-by-line, stretching or squeezing the source line as needed to fit the length available in the target.

I didn't think to post a picture--but I didn't have one in my head at the time anyway. I want to distort, but only left-right, the contents of the square to fit into the contents of the red circle. (I made it easy on myself by making sure the images are the same height...)
MapOneShapeIntoAnother_LtoR.png
MapOneShapeIntoAnother_LtoR.png (12.39 KiB) Viewed 8911 times


I've made progress doing it in Perl, but I've reached the Question:
How to resize a line of pixels while preserving as much fidelity as possible?

...and THAT sounds like GIMP's expertise.

In fact, my problem could be viewed as one of:
How to map pixels contained in one close path in GIMP onto pixels contained in another one?

[1] keeping in mind that nothing is impossible for the person who doesn't have to do it...

Re: G'MIC as Graphic Calculator/Solid-model Generator

Wed Sep 18, 2019 5:44 pm

I think there is a perception problem with your 'heightmaps/depthmaps'.
For example the Grand Canyon appears really deep when looking into it but if viewed from a space station it's just a darker line.

Are you including the distance from/to the center of the earth in the heightmaps?
You maybe taking 'sea level' as your mean point rather than distance from the center of the Earth as the real point of divergence.

Re: G'MIC as Graphic Calculator/Solid-model Generator

Wed Sep 18, 2019 9:00 pm

Tas_mania wrote:I think there is a perception problem with your 'heightmaps/depthmaps'.


My presentation certainly contributed to the perception problem in that the current question has nothing to do with heightmaps/depthmaps. They were just the recent motivation to find a way to process images to fit into different shapes, while maintaining some kind of fidelity.

As I thought about it, it occurred to me that someone else might have already considered the process of "re-mapping" the pixels from one image shape into another shape, but I haven't found anything in the vein of what I want to do.

...and, while I was on the subject of asking if G'MIC could be used for the first problem, it struck me that it would probably be a pretty good way to spin out heightmaps too, at least geometrically interesting ones.

Cheers!

Re: G'MIC as Graphic Calculator/Solid-model Generator

Wed Sep 18, 2019 11:52 pm

Something you could try is type the word 'map' into the G'MIC search box. I get about 20 entries here.

I'm sure somebody must have mentioned Gimp>Filters>Map>Map Object >Map To (Plane, Sphere, Box, Cylinder).
I don't know of other 'map to' abilities in Gimp :)

Re: G'MIC as Graphic Calculator/Solid-model Generator

Thu Sep 19, 2019 9:41 am

I actually want to have G'MIC calculate the pixel values for a heightmap representing, say, a perfect hemisphere.

Re: G'MIC as Graphic Calculator/Solid-model Generator

Thu Sep 19, 2019 5:33 pm

calculate the pixel values for a heightmap representing, say, a perfect hemisphere


If it's not animated then you want to map to a sphere.
Why - because 'hemisphere' means 'a half of a sphere'. That means you can't see the other half because it's hidden from view.

Re: G'MIC as Graphic Calculator/Solid-model Generator

Thu Sep 19, 2019 5:48 pm

Here's a heightmap that does not correspond to a half-a-sphere when read/redd into a Computer-aided machining/CAM program; it looks like it "might/could" be one, but mathematically it's not. It's just "eye-balled."
notasphere.png
notasphere.png (80.94 KiB) Viewed 6519 times


G'MIC, I believe, is capable of producing one that perfectly corresponds to a hemisphere. (And in a height map, the top half of a sphere hides the bottom half, so only need the top.)

Re: G'MIC as Graphic Calculator/Solid-model Generator???

Thu Sep 26, 2019 8:44 pm

Hoping to find out more about how G'MIC Cartesian Transform parses its arguments, I visited G'MIC's Brain Central and there discovered that G'MIC is discussed on other fora as well as here.

I thought perhaps the topic had been touched on in one of those, but I posted in the [urlhttps://discuss.pixls.us/t/gmic-gimp-plug-in-use-it-to-plot-intensity-as-function-of-x-y/14223/3]first one I visited[/url] and was fortunate to get a very quick answer from Prof. Tschumperle (known here as @Ronounours I think).

Given the demands on his time, and his undoubted interest in supporting G'MIC as widely as possible, I'm repeating his, short, response here, along with the sample image showing the sinc() function I'd requested. (I hope this is acceptable, and I do not intend to make it a habit. I apologize if this violates accepted use.)
If you want to generate an image from i(x,y) = formula, then the filter Colors / User-Defined is something to investigate


His image:

Re: [SOLVED] G'MIC as PixelIntensityCalculator/Heightmap Generator YES

Thu Sep 26, 2019 9:08 pm

Try this for a mathematically correct hemisphere:

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


and see what I mean. (Yes, G'MIC can compute heightmaps!)

Re: [SOLVED] G'MIC as Pixel Intensity Calculator/Heightmap Generator??

Thu Sep 26, 2019 10:56 pm

The solution was beyond the contributors here. It does produce what you wanted. The RGBA Normalisation seems to show thats it's pretty much perfect.

Re: [SOLVED] G'MIC as Pixel Intensity Calculator/Heightmap Generator??

Fri Sep 27, 2019 9:32 am

@Tas,
Permit me to take gentle issue with that statement. ;) I see the most beautiful creations here, and very often, when I see one, I start imagining the steps to re-create it,... and then I have to lie down. My "creativity" is really just tenacity in fancy-ball dress.

I expect now that that particular G'MIC's function's ice is broken, other GC members will step forward (Lyle? Wallace? [44]) and show us "here's how." :D As in, "Hey, gramps, where's the color??"

Note [44]: Edited."but especially PegLeg44!"
Post a reply