It is currently Thu Jul 04, 2024 1:16 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: [SOLVED] G'MIC as Pixel Intensity Calculator/Heightmap Generator???
PostPosted: Tue Sep 17, 2019 8:11 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
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:
Attachment:
GIMP_AfrBEFAFT.gif
GIMP_AfrBEFAFT.gif [ 175.17 KiB | Viewed 8980 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.

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


Last edited by gramp on Thu Sep 26, 2019 8:45 pm, edited 2 times 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: G'MIC as Graphic Calculator/Solid-model Generator
PostPosted: Tue Sep 17, 2019 10:13 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
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:
Attachment:
ProfileMap_WrapMap.png
ProfileMap_WrapMap.png [ 82.95 KiB | Viewed 8963 times ]



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

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


Top
 Post subject: Re: G'MIC as Graphic Calculator/Solid-model Generator
PostPosted: Tue Sep 17, 2019 1:15 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
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

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


Top
 Post subject: Re: G'MIC as Graphic Calculator/Solid-model Generator
PostPosted: Wed Sep 18, 2019 4:37 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1365
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


Top
 Post subject: Re: G'MIC as Graphic Calculator/Solid-model Generator
PostPosted: Wed Sep 18, 2019 7:02 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
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...)
Attachment:
MapOneShapeIntoAnother_LtoR.png
MapOneShapeIntoAnother_LtoR.png [ 12.39 KiB | Viewed 8903 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...

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


Top
 Post subject: Re: G'MIC as Graphic Calculator/Solid-model Generator
PostPosted: Wed Sep 18, 2019 5:44 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1365
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.


Top
 Post subject: Re: G'MIC as Graphic Calculator/Solid-model Generator
PostPosted: Wed Sep 18, 2019 9:00 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
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!

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


Top
 Post subject: Re: G'MIC as Graphic Calculator/Solid-model Generator
PostPosted: Wed Sep 18, 2019 11:52 pm  (#8) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1365
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 :)


Top
 Post subject: Re: G'MIC as Graphic Calculator/Solid-model Generator
PostPosted: Thu Sep 19, 2019 9:41 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
I actually want to have G'MIC calculate the pixel values for a heightmap representing, say, a perfect hemisphere.

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


Top
 Post subject: Re: G'MIC as Graphic Calculator/Solid-model Generator
PostPosted: Thu Sep 19, 2019 5:33 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1365
Quote:
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.


Top
 Post subject: Re: G'MIC as Graphic Calculator/Solid-model Generator
PostPosted: Thu Sep 19, 2019 5:48 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
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."
Attachment:
notasphere.png
notasphere.png [ 80.94 KiB | Viewed 6510 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.)

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


Top
 Post subject: Re: G'MIC as Graphic Calculator/Solid-model Generator???
PostPosted: Thu Sep 26, 2019 8:44 pm  (#12) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
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.)
Quote:
If you want to generate an image from i(x,y) = formula, then the filter Colors / User-Defined is something to investigate


His image:


Attachments:
File comment: Screenshot of GIMP G'MIC->Colors->User-Defined menu.
GMIC_Colors_UserDefined_Ixy.png
GMIC_Colors_UserDefined_Ixy.png [ 62.42 KiB | Viewed 6449 times ]

_________________
--
GraMP
"Once you sit on your glasses, the rest of getting old seems obvious."
Top
 Post subject: Re: [SOLVED] G'MIC as PixelIntensityCalculator/Heightmap Generator YES
PostPosted: Thu Sep 26, 2019 9:08 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
Try this for a mathematically correct hemisphere:

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!)

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


Top
 Post subject: Re: [SOLVED] G'MIC as Pixel Intensity Calculator/Heightmap Generator??
PostPosted: Thu Sep 26, 2019 10:56 pm  (#14) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1365
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.


Top
 Post subject: Re: [SOLVED] G'MIC as Pixel Intensity Calculator/Heightmap Generator??
PostPosted: Fri Sep 27, 2019 9:32 am  (#15) 
Offline
GimpChat Member
User avatar

Joined: Apr 20, 2011
Posts: 287
Location: Dane-ish Co., West Gonsin
@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!"

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


Top
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Line/pixel size doesnot correspond with pixel resolution

3

No new posts High Intensity Texture Mapping

0

No new posts Attachment(s) background generator

2

No new posts Really cool pattern generator site - FREE

8

No new posts Attachment(s) Pixel Art Help

2



* Login  



Powered by phpBB3 © phpBB Group