Image to pointcloud script not working correctly on Mac

The script below creates a color pointcloud from a bitmap image with one point=one pixel. This runs perfectly on Windows, even with fairly large numbers of pixels. However, on Mac, it only works with small images, above a certain size, first it has anomalies - black or noise areas - and as size increases, it crashes the release version of Mac Rhino; the WIP does seem to handle the larger images without crashing, but the anomalies remain.

Now, I only have an old MBP with 8Gb of RAM, but I don’t think it’s running out of memory…

If anyone wants to test (@Alain ? ) and tell me if they see the same thing, it would be good to know if it is a general bug, or some way I could structure the script differently to work correctly on Mac. I know his is a delicate area, as there is some sort of interpretation of Windows System.Drawing going on on the Mac side and it’s not yet fully functional…

Anyway, below is a zip with the script and 4 sample images - the 200 height works fine, the 300 height does not crash but has a black area on the right, 400 or larger crashes 5.0.2 consistently, does not crash the WIP, but the black area remains on the right side of the image. When running the script, just accept the default width value (Enter) and use 0 for the insertion point. (372.5 KB)

Thanks, --Mitch

Hey Mitch,

    # pc = Rhino.Geometry.PointCloud()
    # for i in range(iw):
    #     for j in range(ih):
    #         color=img.GetPixel(i,j)
    #         pt=Rhino.Geometry.Point3d(xo+(i*cellsize),yo-(j*cellsize),ipt.Z)
    #         pc.Add(pt, color)

    coords = itertools.product(range(iw), range(ih))
    points = []
    colors = []
    for c in coords:
        points.append(Rhino.Geometry.Point3d(xo + (c[0]*cellsize), yo - (c[1]*cellsize), ipt.Z))
    pc = Rhino.Geometry.PointCloud(points)
    for pci, c in zip(pc, colors):
        pci.Color = c

The managed code calls into the native code for every point added to the point cloud and there’s a problem when it’s done too many times. Adding all the points at once and iterating over the point cloud items to set the color seems to work. Hopefully that’s a good enough workaround until we fix it.


Hi Alain,

Thanks for the workaround… Odd that adding the colors later works better.

However, an image with about 750K points takes 5 seconds to create on my Windows box but around 35 seconds on my old MBP… Now I know the processor is somewhat slower, but not 7 times slower…

Cheers, --Mitch