CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > OpenSource CNC Design Center > OpenSource Software


OpenSource Software For the Discussion of Opensource CAD/CAM and NC shareware software etc)


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 12-17-2004, 08:44 PM
 
Join Date: Nov 2004
Location: DK
Posts: 27
rackbox is on a distinguished road
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...
Tweet this Post!Share on Facebook
Reply With Quote

  #2   Ban this user!
Old 12-17-2004, 08:53 PM
 
Join Date: Nov 2004
Location: DK
Posts: 27
rackbox is on a distinguished road
Oh, forgot!

Forgot to say, that Gcode output might not be 100% compliant, but it works in CNCSimulator...
Tweet this Post!Share on Facebook
Reply With Quote

  #3   Ban this user!
Old 02-06-2005, 06:01 AM
 
Join Date: Feb 2005
Location: The Netherlands
Posts: 120
fantasy2 is on a distinguished road
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.
Tweet this Post!Share on Facebook
Reply With Quote

  #4  
Old 02-28-2005, 10:04 AM
joecnc2006's Avatar
www.joescnc.com
 
Join Date: Aug 2004
Location: usa
Posts: 3,055
joecnc2006 is on a distinguished road
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
Tweet this Post!Share on Facebook
Reply With Quote

  #5   Ban this user!
Old 06-10-2005, 10:50 PM
 
Join Date: Jun 2005
Location: USA
Posts: 55
rherman is on a distinguished road
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
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 06-11-2005, 09:04 PM
 
Join Date: Jun 2005
Location: USA
Posts: 1
johncountryman is on a distinguished road
Rob,
I'm interested in your Gcode program
that generates a numeric grid of your grey-scale image files.
jcountryman1@mn.rr.com
Tweet this Post!Share on Facebook
Reply With Quote

  #7   Ban this user!
Old 06-27-2005, 11:24 AM
 
Join Date: Jun 2005
Location: USA
Posts: 55
rherman is on a distinguished road
Still working on it! I'll only release it when it is further along. I'll let you know. Thanks.

Rob
Tweet this Post!Share on Facebook
Reply With Quote

  #8   Ban this user!
Old 06-27-2005, 03:45 PM
 
Join Date: Jun 2005
Location: CANADA
Posts: 90
the_paco is on a distinguished road
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/
Tweet this Post!Share on Facebook
Reply With Quote

  #9   Ban this user!
Old 07-11-2005, 01:17 AM
 
Join Date: Jun 2005
Location: USA
Posts: 55
rherman is on a distinguished road
Certainly. I have to get back to it. I've been swamped making my rent and bills. Thanks.

Rob
Tweet this Post!Share on Facebook
Reply With Quote

  #10  
Old 07-11-2005, 02:34 AM
Moderator
 
Join Date: Feb 2005
Location: USA
Age: 52
Posts: 672
Halfnutz is on a distinguished road
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)
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 07-18-2005, 05:54 PM
 
Join Date: Jun 2005
Location: USA
Posts: 55
rherman is on a distinguished road
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
Tweet this Post!Share on Facebook
Reply With Quote

  #12   Ban this user!
Old 07-21-2005, 11:27 AM
Death Adder's Avatar  
Join Date: Jul 2005
Location: USA
Age: 31
Posts: 180
Death Adder is on a distinguished road
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.
Tweet this Post!Share on Facebook
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


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




All times are GMT -5. The time now is 08:35 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353