stippled line variable point spacing from raster
 1-10  11-30  31-50  51-60

Previous
Next
 From:  bemfarmer
10809.11 In reply to 10809.5 
I do not see any method to get the pixel values from MoI Image, underlying some curve.
Unless there is some way to translate MoI coordinates into canvas Image coordinates.
Assume the curve is horizontal, beginning at the left of the MoI Image, and extending to the right of the MoI Image.
Let the number of horizontal pixels in the canvas image be hNum, and the number of vertical pixels in the canvas image be vNum.
Place hNum+1 points on the curve, as an array. The array index is the canvas Image x coordinate.


Figure out the vertical pixel value by dividing the image vertically into vNum+1 parts... ... to get the canvas Image y coordinate. (constant)
Figure out which vertical division the curve passes through.

Then the luminosity for each point on the curve can be looked up from the canvas Image, using the canvas methods .data.

Use the pixels values as per the algorithm outline from previous post. Fix the algorithm of course.

Max's Heightmap uses canvas context.
The pixel values are available, as per Ed's 1+ links.

- Brian

All MoI Points in some rectangle would be above one canvas image pixel.
For each canvas image pixel, there would be a rectangle in MoI, with all points in the rectangle above said pixel.

There is a lot that I do not understand.

EDITED: 10 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10809.12 In reply to 10809.11 
The following link has a formula for luminosity.

https://css-tricks.com/manipulating-pixels-using-canvas/

Gray = 0.21R + 0.72G + 0.07B // Luminosity

There are several formulas for gray, and lots and lots of information...

- Brian

There is also code for a canvas full of "noise" or "static", like Max's site now shows.

Each pixel has 4 .data values.


def luminance(pixel): #returns the luminance of a pixel, used in other functions
luminance = (getRed(pixel)+getGreen(pixel)+getBlue(pixel))/3
return luminance

EDITED: 10 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10809.13 
From 2011:
https://moi3d.com/forum/index.php?webtag=MOI&msg=4238.2
4238.2 In reply to 4238.1
Hi Janne - the background images displayed in a viewport have to be generated as a texture that is sent to your video card, and it used to be common for many video cards to have a limit on the size of textures that they supported and to also only have a limited amount of space available on them to hold the textures.

So, what is "texture", versus luminance.
A guess would be that "texture" does not have any luminance value?
Can the image "texture" below a point in MoI screen be directly acquired? Would it be of any use as "luminance" gradient?

If so, converting point coordinates from MoI, to pixel coordinates in canvas image, would be required to work from image in MoI?

Or else do all work in nodeeditor, on nodeeditor canvas.
?

EDITED: 11 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10809.14 
Search for +ImageToRect.js does not have any results.

Found it:
https://moi3d.com/forum/index.php?webtag=MOI&msg=10730.7

- Brian

EDITED: 11 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pressure (PEER)
10809.15 In reply to 10809.14 
Brian,

Thanks for all of the ideas! I especially like iterating along a curve by iterating over an array of points on the curve since I had no clue about how I might do that otherwise.

I played around with HeightMap, though how it reads in image data is beyond my grasp. I haven't tried nodeeditor, but I looked at imagesampler.js and it's clearer to me there how the pixels are being read. It's good to know that I could do this on a nodeeditor canvas, though I worry that will create the problem of placing the results into the 3D world. I'll try out nodeeditor to get a feel for it.

I wrote out pseudocode over breakfast and the missing link is mapping 3D world coordinates to pixel coordinates, as you brought up in relation to texture maps. I see how I might do this with some manual input by using fiducial marks on the image, but I'm going to ask Michael if there's a way to get the coordinates of a background image directly.

Solving this problem purely in MoI may be beyond my limited abilities, so I'm going to try a last ditch solution with other software before I dig deeper into a script or node solution.

What does +imagetorect.zip do?

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pressure (PEER)
10809.16 In reply to 10809.10 
Ed,

Thank you for pointing out line 30 in _Heightmap.js. I'm not familiar with javascript or an html canvas, but the Mozilla link you posted gave me some inkling. I'll play around with getImageData() and see what I can do. The additional resources that you posted relating to image brightness should get me there.

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pressure (PEER)
10809.17 In reply to 10809.2 
Michael,

Thanks for the node links and Grasshopper recommendation. Brian and Ed have gotten me to the point of understanding that mapping between MoI 3D world units and pixels will be a problem. I could probably do it manually by putting some fiducial marks on the raster in photoshop and then manually place point objects on the fiducials as they appear in the 3D scene. I'm wondering if there's a better way.

I went through http://web.archive.org/web/20180705035034/http:/moi.maxsm.net/api and found these methods and properties related to background images:

fileName
hidden
remove
backgroundImageDrawOrder
backgroundImageShowIn
backgroundImageTransparency
getBackgroundImages
alignbackgroundimage
backgroundimage

In the GUI I can see View > Image > Properties Width and Height. Can I retrieve Width and Height in a script?

Are there any methods or properties that would allow me to find coordinates of 3 corners of a background image?

Can I find a mapping between the corners of the displayed background image and the corners of the bitmap file from which it was generated? In other words, map the corners even if the displayed background image is rotated, mirrored, or scaled.

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10809.18 In reply to 10809.15 
Link to ImageToRect.js
https://moi3d.com/forum/index.php?webtag=MOI&msg=10730.7

Placed the image in a rectangle.

- Brian

function AddImage() in commands\Image.js: Link:
https://moi3d.com/forum/index.php?webtag=MOI&msg=8571.7

EDITED: 11 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10809.19 In reply to 10809.14 
Hi Brian,

re:
> Search for +imagetorect.zip does not have any results.
> I downloaded imagetorect.zip on 6/24/2022.
>
> Where are the forum posts about this new script?

It's here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=10730.7

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10809.20 In reply to 10809.17 
Hi Peer,

re:
> In the GUI I can see View > Image > Properties Width and Height. Can I retrieve Width and Height in a script?

Yes, they are available in script as .width and .height properties on a background image.

> Are there any methods or properties that would allow me to find coordinates of 3 corners of a background image?

Yes, the .frame property on a background image object gives a MoiCoordinateFrame object which is made up of an origin point and x/y/z axis directions forming a coordinate system. The bottom left corner of the image is located at the origin point of that frame and extends by width amount along the x axis direction and by height amount along the y axis direction.

The points can be obtained like this (warning untested code):

var lower_left = img.frame.origin;
var lower_right = img.frame.evaluate( img.width, 0 );
var upper_right = img.frame.evaluate( img.width, img.height );
var upper_left = img.frame.evaluate( 0, img.height );

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pressure (PEER)
10809.21 In reply to 10809.20 
Thanks Michael!

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10809.22 In reply to 10809.19 
Thank you Michael.

Is there any way to get the RGB value of a point in the image file? Or some connection between image pixels and MoI screen point coordinates?
Does it have anything to do with "texture" (texels?)
Is the image file somewhere in the geometry database.
Please excuse my dumb questions.

- Brian


I do not know anything about "texture"
Found a link with a kitten:
https://www.cs.uregina.ca/Links/class-info/315/WWW/Lab5/

"Textures--rectangular arrays of data. The data can be color data, luminance data, or color and alpha data"
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10809.23 In reply to 10809.22 
Hi Brian,

re:
> Is there any way to get the RGB value of a point in the image file? Or some connection between
> image pixels and MoI screen point coordinates?

There isn't anything for that in MoI's own script interface but you can use one of the HTML documents that are used for MoI's UI to access image pixel data in a script.

Like Ed writes above, check out Max's heightmap command for an example. I've attached it.

- Michael

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10809.24 In reply to 10809.23 
Thank you Michael.

I now think that there is enough information to map a MoI point over an image, into the original "canvas" image pixel array.
For one canvas image pixel, there are 4 entries in the array, R value, G value, B value, and Alpha value.

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10809.25 In reply to 10809.23 
Michael, Thank you for the most recent version of Heightmap.
It works in MoI5beta as well.
(The pixel width count of the two images that I tried were cut in half.)
Heightmap has a lot of the required code.


Raster gradients can be produced in imagemagick, a free program.
https://imagemagick.org/script/gradient.php
There are numerous versions, including 6 Windows versions and 1 Mac OS version.
De to lack of experience, I am not expressing any opinion expressed about the worth of this program.

- Brian

Does MoI Image command work with image files with 8 or 16 bits-per-pixel,
Static, or dynamic, (Whatever those mean), or HDRI (high dynamic-range imaging)?

EDITED: 11 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10809.26 In reply to 10809.25 
Hi Brian,

re:
> Does MoI Image command work with image files with 8 or 16 bits-per-pixel,
> Static, or dynamic, (Whatever those mean), or HDRI (high dynamic-range imaging)?

It only works with images in PNG, TIF, JPEG, GIF, and BMP formats and I don't think that any of those can contain HDRI image data.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10809.27 
This link has some generic code for "transforming the coordinates from the specified coordinate system into pixel coordinates."
(2.1.2 Real-number Coordinate Systems)

https://math.hws.edu/graphicsbook/c2/s1.html#:~:text=In%20terms%20of%20coordinates%2C%20a,to%20right%2C%20starting%20with%20zero.

One step is to set up the various image rectangles. These are world, local, canvas, and primary.
MoI World coordinates come from MoI Local (cplane) coordinates using .evaluate. (See Michaels code.)

The primary image is the source PNG, TIF, JPEG, GIF, or BMP.
A primary image ( width, height ) ( 1920, 1080 ), has 1920 pixel columns, and 1080 pixel rows.
A test primary image will be ( 6, 5 ). (or maybe ( 12, 8 ).

The address for a pixel is ( rowNum, colNum )
the pixel columns and rows are zero indexed, with upper left corner ( 0, 0, 0 ).

The canvas image is similar to the primary image. (?) (Heightmap divides x by 2)
Reversing row number from bottom to top to top to bottom: ( oldrowNumber - numRows ) ?

- Brian

I am going to assume that a screen point that falls on a pixel boundary is in the pixel to the left, or above. (???)
Except uppermost edge and leftmost edge?

EDITED: 12 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10809.28 
Based upon Peer's initial description:

I am thinking that the "intensity-to-points-array" should be done from a 2d CPlane.
Convert CPlane local coordinates over the image, into pixel (row,column) address of the canvas image.
World coordinates just complicate the script.
At the end of the script, the CPlane can be reset.

The reason for this is that the 2d image can be in any view, for example Top, Front, Right, etc.
Or even at some other angle. The ( X, Y ) coordinate of a local point is to be converted to a pixel address.
World coordinates could introduce z into the (x,y) mix, and mess up the conversion to pixel address.
For example, Front view is 2d world ( x, z ), but local ( X, Y ), with Z = 0, or Z = constant.
Right view is 2d world ( y, z ), but local ( X, Y ), with Z = 0, or Z = constant.

?

- Brian

I'll make the assumption that the canvas image is the same "resolution" as the primary (e.g. PNG) image.
I guess that the canvas image is somewhere in memory, not a MoI geometry object. (?)

The method to ghet the 2d CPlane of an image was given by Michael, I think.

So divide the local image by columnNum zones, along X,
and divide the local image by rowNum zones, along Y.
(Convert real number X, Y coordinates into integers for each zone...)
Reverse Y coordinates for rowNum to be zero at upper left corner.

EDITED: 12 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10809.29 In reply to 10809.5 
Hi PEER,

>>>But maybe before going into details, can you think of another way of spacing out points along a curve so the the distance between each pair of points is roughly proportional to the local luminance of an underlying image? Maybe there's a straighter path that I'm not thinking of.

If you have a mathematical formula for the "raster gradient" of the luminance, that could perhaps be used to array the points along the curve.

The programs that create the raster gradients use some mathematical method. See their source code, or do internet search?

https://gis.stackexchange.com/questions/311688/how-to-make-a-raster-gradient-in-any-direction-in-r

https://www.i-programmer.info/programming/javascript/14966-javascript-canvas-gradient-a-pattern-fills.html

https://blog.johnnovak.net/2016/09/21/what-every-coder-should-know-about-gamma/

https://www.youtube.com/watch?v=nMUMZ5YRxHI

- Brian

EDITED: 12 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pressure (PEER)
10809.30 In reply to 10809.29 
Brian,

I got pretty close to what I want working in another program. For now I'm going to use that.

Have a good weekend!

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
Show messages:  1-10  11-30  31-50  51-60