![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| OpenSource Software For the Discussion of Opensource CAD/CAM and NC shareware software etc) |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
| Image (Greyscale) to GCODE Hehe! I have just made a small program that makes gcode of greyscale or B&W images. It is not yet finished, as I don't yet have a CNC mill, but you are welcome to use it and alter or redistribute it, if you find it useful. It's written in PHP and takes image.png as the image file. Also $x_max, $y_max and $z_max are set to set the image size when carved. I haven't yet found a way for the image not to be mirrored and also there are no way of choosing milling diameter or steps. But look at it, use it and see what you can do: Mind that all the "n"'s should be preceded by a backslash... Also there might be other small stuff lost in the conversion to this post. HTML Code: <?php $file = "image.png"; $im = imagecreatefrompng($file); $size_arr = getimagesize($file); $x_max = 800; $x_factor = $size_arr[0]; $y_max = 800; $y_factor = $size_arr[1]; $z_max = 40; $z_factor = 256; $last_x = 0; $last_y = 0; $last_z = 0; echo "G01 X0 Y0 Z0\n"; for ($y=$size_arr[1]; $y>0; $y--) { for ($x=0; $x<$size_arr[0]; $x++) { $rgb = ImageColorAt($im, $x, $y); $z = $rgb; $x_pos = ($x/$x_factor*$x_max); $y_pos = ($y/$y_factor*$y_max); $z_pos = -($z/$z_factor*$z_max); echo "G01"; if ($x_pos != $last_x){ echo " X".$x_pos; $last_x = $x_pos; } if ($y_pos != $last_y){ echo " Y".$y_pos; $last_y = $y_pos; } if ($z_pos != $last_z){ echo " Z".$z_pos; $last_z = $z_pos; } echo "\n"; } } ?> Last edited by rackbox; 12-17-2004 at 08:49 PM. Reason: Seems that code is not very well accepted... |
|
#2
| |||
| |||
| Oh, forgot! Forgot to say, that Gcode output might not be 100% compliant, but it works in CNCSimulator... |
|
#3
| |||
| |||
| Hi, I think I'm the first one who tests your software... I'm also a php programmer. Your code seems to loop very long and I think there are still some errors. When testing a sample picture I get a Z of: Z-2621439.84375 Shouldn't be correct so I won't test it on my machine yet. |
|
#4
| ||||
| ||||
| Any new development of this code? I'm not a programer but looking for something for pictures to engrave, Not for buiseness but personal so cost is an issue. and just wondering how this works? Thanks, Joe |
|
#5
| |||
| |||
| Joe, Email me, I'm working on something cool and opensource. Check out my user (rherman) gallery on this site for pics. Rob Last edited by rherman; 06-10-2005 at 10:52 PM. Reason: Hit Submit key before finished |
| Sponsored Links |
|
#6
| |||
| |||
| Rob, I'm interested in your Gcode program that generates a numeric grid of your grey-scale image files. jcountryman1@mn.rr.com |
|
#7
| |||
| |||
| Still working on it! I'll only release it when it is further along. I'll let you know. Thanks. Rob |
|
#8
| |||
| |||
| Wow!!! Cool!!! I'm interested (VERY)... I'd like to try/test it. Keep us informed of your project rherman.
__________________ My business Web site - USINUM - www.cooptel.qc.ca/~usinum My BLOG at Blogger - http://pacosarea.blogspot.com/ |
|
#9
| |||
| |||
| Certainly. I have to get back to it. I've been swamped making my rent and bills. Thanks. Rob |
|
#10
| |||
| |||
| Vitrtual Sculpter 3D is a nice grayscale to DNC program with a free 30 day demo version. Do a search on the net if you want to have something for thirty days anyway. It sems like a very good program, I used it a couple of times but my trial ran out.
__________________ Halfnutz (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management) |
| Sponsored Links |
|
#11
| |||
| |||
| Yes, I came upon VS3D after I started my program. It is a very good program. I didn't need the cam side of it, however, and I am trying to create algorithms specifically for portraiture taking the hand work out of creating reliefs. Rob |
|
#12
| ||||
| ||||
| This sounds interesting. The ability to specify tool diameter and pick distance would be nice. I noticed in your PHP code that you step one way through the image array. This is not good because at the end of one line it will gouge through the part to get to the start of the next line (potentially anyways). It would be better to scan through a line, move to the next line and go through that one in the reverse direction. That way you get no gouging. I might code up something like this myself. I've got a C backend VB front end program that I wrote a while back that does some nifty CNC operations plus does some research related things (like creating octrees and visualizing them in OpenGL). I might try to add something like this to it. Or maybe I'll make it a seperate program. I hope you don't mind if I try to do what you are doing but in C instead of PHP. A neat thing you might be able to do is make your PHP code accessable over a website so that people can upload their PNG files and get the GCODE output right over the internet. That'd be COOL. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Autocad to gcode | JamesMI | Autodesk Software (Autocad, Inventor etc) | 17 | 12-02-2011 03:54 AM |
| Is it possible to get a gcode into Rhino | MrBean | Rhino 3D | 11 | 04-03-2005 08:41 AM |
| gcode to gcode converter | july_favre | General CAM Discussion | 4 | 05-24-2004 07:51 PM |
| Easily trace an image into your CAD | Graphcon | Product Announcements & Manufacturer News | 0 | 11-14-2003 07:30 AM |
| Gcode verify autocad plugin | balsaman | General CAM Discussion | 1 | 10-31-2003 12:22 PM |