POV-Ray : Newsgroups : povray.general : Height field to mesh - more resolution Server Time
30 Dec 2024 12:15:57 EST (-0500)
  Height field to mesh - more resolution (Message 22 to 31 of 31)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: ingo
Subject: Re: Height field to mesh - more resolution
Date: 8 Dec 2023 05:20:00
Message: <web.6572edc02c1eda4417bac71e8ffb8ce3@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:
> Here's the code, [...]
> Have Fun!

Leroy,

reading onther ones code is always a problem for me. Is the following what you
are doing?


Interpolate image:
create array with the size of the new image

.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .


Fill the array positions with values from image in proper locations (*)

* . . . * . . . * . . . *
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
* . . . * . . . * . . . *
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
* . . . * . . . * . . . *
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
* . . . * . . . * . . . *


Use the values on rows to create a spline.
Use spline to fill gaps (x)

* x x x * x x x * x x x *
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
* x x x * x x x * x x x *
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
* x x x * x x x * x x x *
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
.. . . . . . . . . . . . .
* x x x * x x x * x x x *


Use the values on cols to create a spline.
Use spline to fill gaps (y)

* x x x * x x x * x x x *
y y y y y y y y y y y y y
y y y y y y y y y y y y y
y y y y y y y y y y y y y
* x x x * x x x * x x x *
y y y y y y y y y y y y y
y y y y y y y y y y y y y
y y y y y y y y y y y y y
* x x x * x x x * x x x *
y y y y y y y y y y y y y
y y y y y y y y y y y y y
y y y y y y y y y y y y y
* x x x * x x x * x x x *


If so there is an alternative method:

Use the values on cols to create a spline.
Use spline to fill gaps (y)

* x x x * x x x * x x x *
y . . . y . . . y . . . y
y . . . y . . . y . . . y
y . . . y . . . y . . . y
* x x x * x x x * x x x *
y . . . y . . . y . . . y
y . . . y . . . y . . . y
y . . . y . . . y . . . y
* x x x * x x x * x x x *
y . . . y . . . y . . . y
y . . . y . . . y . . . y
y . . . y . . . y . . . y
* x x x * x x x * x x x *


Detail top left

x1y1  x2y1  x3y1  x4y1  x5y1
x1y2  .     .     .     x5y2
x1y3  .     .     .     x5y3
x1y4  .     .     .     x5y4
x1y5  x2y5  x3y5  x4y5  x5y5

for example to fill the centre dot,
construct spline through x3y1, x3y5 and a spline x1y3, x5y3
get the value of both splines for x3y3 and average those.

Is it better? Pff, what is better? Does it give a different result, yes. It is
closer to the algorithms for bicubic image interpolation.

Thanks for your code.


ingo


Post a reply to this message

From: Leroy
Subject: Re: Height field to mesh - more resolution
Date: 8 Dec 2023 15:45:00
Message: <web.65737f2d2c1eda447de25836f712fc00@news.povray.org>
"ingo" <nomail@nomail> wrote:
> "Leroy" <whe### [at] gmailcom> wrote:
> > Here's the code, [...]
> > Have Fun!
>
> Leroy,
>
> reading onther ones code is always a problem for me. Is the following what you
> are doing?
>
>
> Interpolate image:
> create array with the size of the new image
>
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
>
>
> Fill the array positions with values from image in proper locations (*)
>
> * . . . * . . . * . . . *
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> * . . . * . . . * . . . *
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> * . . . * . . . * . . . *
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> * . . . * . . . * . . . *
>
>
> Use the values on rows to create a spline.
> Use spline to fill gaps (x)
>
> * x x x * x x x * x x x *
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> * x x x * x x x * x x x *
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> * x x x * x x x * x x x *
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> .. . . . . . . . . . . . .
> * x x x * x x x * x x x *
>
>
> Use the values on cols to create a spline.
> Use spline to fill gaps (y)
>
> * x x x * x x x * x x x *
> y y y y y y y y y y y y y
> y y y y y y y y y y y y y
> y y y y y y y y y y y y y
> * x x x * x x x * x x x *
> y y y y y y y y y y y y y
> y y y y y y y y y y y y y
> y y y y y y y y y y y y y
> * x x x * x x x * x x x *
> y y y y y y y y y y y y y
> y y y y y y y y y y y y y
> y y y y y y y y y y y y y
> * x x x * x x x * x x x *
>
>
> If so there is an alternative method:
>
> Use the values on cols to create a spline.
> Use spline to fill gaps (y)
>
> * x x x * x x x * x x x *
> y . . . y . . . y . . . y
> y . . . y . . . y . . . y
> y . . . y . . . y . . . y
> * x x x * x x x * x x x *
> y . . . y . . . y . . . y
> y . . . y . . . y . . . y
> y . . . y . . . y . . . y
> * x x x * x x x * x x x *
> y . . . y . . . y . . . y
> y . . . y . . . y . . . y
> y . . . y . . . y . . . y
> * x x x * x x x * x x x *
>
>
> Detail top left
>
> x1y1  x2y1  x3y1  x4y1  x5y1
> x1y2  .     .     .     x5y2
> x1y3  .     .     .     x5y3
> x1y4  .     .     .     x5y4
> x1y5  x2y5  x3y5  x4y5  x5y5
>
> for example to fill the centre dot,
> construct spline through x3y1, x3y5 and a spline x1y3, x5y3
> get the value of both splines for x3y3 and average those.
>
> Is it better? Pff, what is better? Does it give a different result, yes. It is
> closer to the algorithms for bicubic image interpolation.
>
> Thanks for your code.
>
>
> ingo

You got my ideal right.
I would go more into it now ,but
I'm on my phone.


Post a reply to this message

From: ingo
Subject: Re: Height field to mesh - more resolution
Date: 9 Dec 2023 03:25:00
Message: <web.657424352c1eda4417bac71e8ffb8ce3@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:

> You got my ideal right.
> I would go more into it now ,but [...]

All clear. The way you "by-pass" the scaling complexities by just inserting N
pixels (the Cut) works well. I may nick that for a Nim implementation.

ingo


Post a reply to this message

From: Ilya Razmanov
Subject: Version update (was Re: Height field to mesh - more resolution)
Date: 22 Dec 2023 23:15:54
Message: <65865efa$1@news.povray.org>
On 30.11.2023 7:59, Ilya Razmanov wrote:

> Meanwhile, I hope someone will find this tiny utility useful, and 
> probably even come with new ideas.
While discussion in general switched to using of POVRay SDL, I guess 
I'll still share the update of initial Python utility, including some 
small bugfixes and stuff.

To reduce my contribution into wasting this server storage space, I 
decided to waste github space instead, so from now on you can download 
updated versions from:

https://github.com/Dnyarri/img2mesh

Ilya


Post a reply to this message

From: Ilya Razmanov
Subject: Re: Height field to mesh - more resolution
Date: 13 Jan 2024 05:04:36
Message: <65a26034@news.povray.org>
On 01.12.2023 10:03, jr wrote:
> "jr" <cre### [at] gmailcom> wrote:
>> Ilya Razmanov <ily### [at] gmailcom> wrote:
>> ...> > For this to be done within POVRay only, I need:
>> aiui, POV-Ray (as of 3.7) has the "tools", ...
> 
> proof of concept (640x480 image source).  ~20 minutes ;-)
Cheating detected: you are using C4 symmetry, while I simulated real 
packing with C3, which requires painful procedure of remembering medium 
school math (funny enough, years ago I started with angular functions; 
much later I managed to remember of Pythagorean theorem, and yesterday - 
a triumph! - I finally managed to make all this down to sqrt(3), which I 
hardcoded as a constant, thus removing all linkage to math, rotflmao. 
The moral is, you should learn math to get rid of it.)

Anyway, some number of the now resides at
https://github.com/Dnyarri/POVmosaic
variants with, say, rotated boxes looks pseudo-artistic enough to start 
boring people with it. Guess I miss C6 symmetry, but "I'll think of it 
all tomorrow".

Ilya.


Post a reply to this message

From: jr
Subject: Re: Height field to mesh - more resolution
Date: 13 Jan 2024 06:30:00
Message: <web.65a274102c1eda447f6d9cf76cde94f1@news.povray.org>
hi,

Ilya Razmanov <ily### [at] gmailcom> wrote:
> On 01.12.2023 10:03, jr wrote:
> > "jr" <cre### [at] gmailcom> wrote:
> >> Ilya Razmanov <ily### [at] gmailcom> wrote:
> >> ...> > For this to be done within POVRay only, I need:
> >> aiui, POV-Ray (as of 3.7) has the "tools", ...
> >
> > proof of concept (640x480 image source).  ~20 minutes ;-)
> Cheating detected:

how so ?  "bog standard" SDL.


> you are using C4 symmetry, while I simulated real
> packing with C3, which requires painful procedure of remembering medium
> school math (funny enough, years ago I started with angular functions;
> much later I managed to remember of Pythagorean theorem, and yesterday -
> a triumph! - I finally managed to make all this down to sqrt(3), which I
> hardcoded as a constant, thus removing all linkage to math, rotflmao.
> The moral is, you should learn math to get rid of it.)
> Anyway, some number of the now resides at {...}
> variants with, say, rotated boxes looks pseudo-artistic enough to start
> boring people with it. Guess I miss C6 symmetry, but "I'll think of it
> all tomorrow".

so there's the confusion, "jr" and "maths" only fit into one sentence when
followed by laughter :-).  I have no idea (yet) what "C3" and "C4" symmetries
might be; on the ever-increasing ToDo list.


> Ilya.


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: Height field to mesh - more resolution
Date: 13 Jan 2024 10:45:00
Message: <web.65a2af052c1eda441f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
I have no idea (yet) what "C3" and "C4" symmetries
> might be; on the ever-increasing ToDo list.

Those are symmetry groups.  They're used to define, and simplify geometric
permustations (at least in chemistry wrt to molecule shapes and electron orbital
/ energy states)
https://en.wikipedia.org/wiki/Group_theory#Chemistry_and_materials_science

https://en.wikipedia.org/wiki/Group_theory

C refers to a cylcical group, where the number refers to how many dicrete ways
you can arrange something and have it be "different".

A circle is C1
A "double semicircle", theta, "half moon" is C2, since you can rotate it 180
deg, and so you have 2 symmetric orientations.
triangles C3
Squares C4
pentagons C5
Hexagons C6

It gets a bit complicated when you start looking at even the simple, yet
non-trivial structures
https://www.globalsino.com/EM/page3137.html

which is every bit as "fun" as it looks.  Especially when your Inorganic
Chemistry professor is ... special.  ;)

It would certainly be interesting to have a library of transforms that would
reorient things based upon symmetry groups, and then it would probably be
possible to analyze a given object to determine what symmetry group it was
in....

(and NO, at this point I'm not doing that.  :P  )


- BW


Post a reply to this message

From: Ilya Razmanov
Subject: Re: Height field to mesh - more resolution
Date: 13 Jan 2024 12:45:45
Message: <65a2cc49$1@news.povray.org>
On 13.01.2024 14:29, jr wrote:
>
> I have no idea (yet) what "C3" and "C4" symmetries
> might be
> regards, jr.
> 

C3 is triangle tiling ("parquet"), while C4 is square parquet. It's easy 
to visualize bitmap image as square pixel parquet and, therefore, turn 
it into C4 tiling of some 3D objects, having the same step distance 
along both x and y axes. With C3, however, step along one axis (in my 
version, x) is equal to triangle side (which, in my case, is 
2*sphere_radius), while step along the other (in my version, y) is equal 
to triangle height (which would be sqrt(3)*sphere_radius). As a result, 
if you compare my s4zaika and s3zaika programs, both have just two 
nested loops along y and x, across the image, but s4zaika have a normal

for y in range(0, Y, 1):

loop, while s3zaika have some weird

triangleheight = 0.5 * 1.7320508075688773
Ycount = int(Y/triangleheight)
for y in range(0, Ycount, 1):

loop, where 0.5 is the sphere radius; and apparently reads source PNG 
pixels with non-integer coordinates; all this requires some work from my 
rusty more than 0.5*century old encephalon :-)

So, now I have C2 (hidden inside C4 sourcecodes), C3 and C4; C5 does not 
exist, as do not C7 and above; so I have only C6 ("honeycomb") remain 
uncovered. But it need remembering some more school math...

Ilya


Post a reply to this message

From: jr
Subject: Re: Height field to mesh - more resolution
Date: 14 Jan 2024 04:10:00
Message: <web.65a3a4302c1eda447f6d9cf76cde94f1@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> I have no idea (yet) what "C3" and "C4" symmetries
> > might be; on the ever-increasing ToDo list.

Ilya Razmanov <ily### [at] gmailcom> wrote:
> ...

thanking both of you for trying to explain, appreciated.  this "symmetries"
stuff is much deeper though than I can "cope with", for now.


regards, jr.


Post a reply to this message

From: Ilya Razmanov
Subject: Height field to mesh - POV, OBJ, STL support
Date: 14 Apr 2024 15:43:37
Message: <661c31e9$1@news.povray.org>
During major update of img2mesh utility for conversion of PNG 
heightfield into 3D mesh in an unusual way (and often better), complete 
rewriting of POVRay export code was made, removing all POVRay transforms 
(and apparently some artifacts) and supposedly making it render a tiny 
bit faster.

Beside that, Wavefront OBJ and stereolithography STL format output 
added. All Python sources available at:

https://github.com/Dnyarri/img2mesh

For Windows users, standalone Win64 exe compiled:

https://github.com/Dnyarri/img2mesh/releases/latest

-- 
Ilyich the Toad
https://dnyarri.github.io/


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.