############################## import rhinoscriptsyntax as rs ### import random, time, sys,System ### sys.path.append("P:/") ### add LW P:/ to rhino's default search path so_that DM2_lib.py can be found ! sys.path.append("P:/ue_04/") ### to find some images import DM_lib as dm ### ############################## reload (dm) rs.ViewDisplayMode(view=None, mode="wireframe") rs.ShowGrid(view=None, show=False) rs.Command("cplane w t enter", False) # cPlane World Top #dm.PointRadius(displayModeX=0, rad=3, styl=2, verbose=True) # 2 square; 3 round #dm.printDisplay(0) # nomen est omen rs.EnableRedraw(False) dm.eA() rs.Redraw() if 1: grayScale = 0 makeEleva = 1 makePoints = 0 makeCurve = 0 intervall = 1 img_name = "hand.jpeg" img_path = img_name ######## pixels = dm.getPixels(img_path, steps_x=intervall, steps_y=intervall) ######## #print ("pixels[0]", pixels[0]) #print ("pixel [0]", pixels[0][0]) #################################### ### make 3D_grafik from pixels_lists: allCoords = [] allColors = [] for y,row in enumerate(pixels[0:]): ### enumerate = generate counter 0,1,2,3,4,5... coords = [] colors = [] for x,col in enumerate(row[0:]): dm.esc() avg = int( (col[0] + col[1] + col[2])/3 ) ### average, for gray_value if grayScale: col = [avg, avg, avg] cor = [x, y, (255-avg)*0.01*makeEleva] coords.append( cor ) colors.append( col ) if 1 or not makeCurve: rs.ObjectColor( rs.AddPoint( cor ), col) allCoords.append( coords ) allColors.append( colors ) if makeCurve: col = dm.pntCentroid(row) for cor in coords: cor[2] *= makeCurve crv = rs.AddCurve( coords, makeCurve) rs.ObjectColor( crv, col) if y%15==0: rs.ZoomExtents() rs.Redraw() if 0: for coords in allCoords: dm.esc() rs.AddCurve( coords, 1) rs.Redraw() ################################# ### save / export the colors_list dm.exportCoordLists( list2export=allColors, exportedListName="allPixels", path="P:/FINALE/annaS/", fileName="MM_pixels_col")