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! > Machine Controllers Software and Solutions > Visual Basic


Visual Basic Discuss Visual Basic programing.


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 04-11-2006, 10:38 PM
 
Join Date: May 2005
Location: USA
Posts: 16
IMSlo is on a distinguished road
Photo Silhoutte (Profile) in VB

I would like to write a VB program that would write GCode to cut a Silhoutte ( I don't know how to spell Silhoutte) from a digital photo. Please don't suggest buying software to do this. I built JGRO's router. SWMBO (for yall who still don't know what that is She Who Must Be Obeyed) does not share nor appreciate my enthusiasm for the CNC router. She says we need new carpet, the bathroom remodeled, and our 30 year old oven replaced. And in fairness to her the router has not done much more than take up space in my already cluttered wood working shop.

I have some expericnce in VB. I have written extensive applications in MSAccess which uses VBA. I have a program that was free on the internet that does a good job of edge detection and the person who wrote it was good enough to allow public access to the source code. The way the program works is after determining the width in x pixels and the height in y pixel it starts at X1 and moves across the entire photo one x pixel at a time. At each x pixel it moves up the y pixels for the entire height of the photo. If a pixel need to be turned on it does it. I can capture the xy position of those turned on pixels. The big problem is that they are far from cnc order. I have begun to try to figure out an algorythm to compute the logical order for cutting and write the Gcode. I would assume that each pixel is a unit. Of course it would have to be scaled down drastically. It seems that there are seven possible positions (9 minus present and last positions) for the next point. This seems relatively simple but there are times when I have seen gaps when zooming in on the edge detection and I have have seen multiple lines. I can imagine the program hanging up looking for a nonexistant point or going back and forth between multiple lines. I have not really started on this project and very possibly might never. I would just like to hear some ideas from others if you would be willing to share.
Tweet this Post!Share on Facebook
Reply With Quote

  #2   Ban this user!
Old 06-08-2006, 12:39 AM
 
Join Date: Jul 2005
Location: USA
Posts: 66
nikolatesla20 is on a distinguished road

Hi, this is possible to do by writing a "following" algorithm which walks the edge of the image. Firstly,however, for a digital photo image you need to do image enhancement using and edge detector called a canny edge detector. The canny detector usually gives you a nice 1 pixel edge. After that you can use an algorithm which will simply follow the edge - basically tracing along it. This will put the pixels in the right order automatically. After that you can then also walk thru the points and calculate the angles between each pixel - if the pixel is straight, for example, like the pixel above the current one is straight above, you could optimize the line by just jumping to that location until a pixel "shift" occurs which would indicate the line is changing direction.

Really you only need basic math to do the more complex stuff, the canny edge detector is the most difficult part to implement, but it is certianly doable even in VB (although it may be a bit slower)

-niko
Tweet this Post!Share on Facebook
Reply With Quote

  #3   Ban this user!
Old 06-08-2006, 10:37 AM
 
Join Date: Mar 2004
Location: Iowa, USA
Posts: 264
rippersoft is on a distinguished road

Here is some research material:
http://www.greyc.ensicaen.fr/~dtschump/greycstoration/
http://potrace.sourceforge.net/
http://www.inkscape.org/
http://www.roitsystems.com/cgi-bin/autotrace/tracer.pl
http://sourceforge.net/projects/autotrace
http://autotrace.sourceforge.net/frontline/

Good Luck,
RipperSoftware
Tweet this Post!Share on Facebook
Reply With Quote

  #4   Ban this user!
Old 06-13-2006, 12:35 PM
 
Join Date: May 2005
Location: USA
Posts: 16
IMSlo is on a distinguished road
Some Progress

Thanks for the replys fellows. It looked as if there would be no replys.
Progress:
I am working with VB Net 2005.
I have the form built.
I can load, crop, and flip/rotate the image.
I am converting the working image to 8bbpindexed monochrome. (Thanks to Bob Powell's tutorials.)
Problems:
I made the image 8 bits per pixel instead of 1 bit per pixel to avoid bit shifting etc. in isolating a pixel.
I made the image only two colors because I thought this would make edge detection easier. I have not been able to accomplish edge detection. The method I have been trying to use compares the current pixel to the left, right, above and below pixels. If it is different from any of these I set the color black. If all are the same I set the pixel white. This should result in a black outline on a white image. I am using Marshal.ReadByte and Marshal.WriteByte to accomplish this. I always end up with a completly white or a completely black image depending on the I set the conditions. I am stumped at present. I must be making some wrong intrepretations. Maybe I will get a revelation during aone of my daily walks.
Tweet this Post!Share on Facebook
Reply With Quote

  #5   Ban this user!
Old 06-13-2006, 02:04 PM
 
Join Date: May 2005
Location: USA
Posts: 16
IMSlo is on a distinguished road
Outline Is working


Just got my outline working. The procedure I was using was right. I was trying to do too much in one step. The photos I am using are already almost silhouttes. They are profiles of my grandaughter taken in front of an outside window. They are backlighted.
During this fiasco I have learned quite a bit about image manipulation in VB Net. Now I am about to get whipped by databases.
I think I will take a walk and then jump into coordinate saving, scaling, sorting,etc etc.
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 06-13-2006, 04:08 PM
 
Join Date: Mar 2004
Location: United States
Posts: 1,147
vacpress is on a distinguished road

imslo - cool...

i would be interested in seeing your code, just out of curiosity. i am trying to increase my vb-based killing power... havent moved to .net yet tho... i am afraid of loosing my beloved object arrays!
Tweet this Post!Share on Facebook
Reply With Quote

  #7  
Old 06-13-2006, 05:38 PM
Switcher's Avatar
Moderator
 
Join Date: Apr 2005
Location: Vectorink.com
Posts: 3,659
Blog Entries: 2
Switcher is on a distinguished road

Check out, "Paint .NET" Open source, written in C# (105,000 lines of code). I know you said VB .NET, maybe you can convert what you need with the last link.

http://www.eecs.wsu.edu/paint.net/download.html#src (Download Source)

http://www.eecs.wsu.edu/paint.net/index.html

http://www.developerfusion.co.uk/uti...sharptovb.aspx (Convert C# to VB.NET)

.
__________________
Free DXF Files - Vectorink.com - myDXF.blogspot.com
Tweet this Post!Share on Facebook
Reply With Quote

  #8   Ban this user!
Old 06-13-2006, 10:27 PM
 
Join Date: May 2005
Location: USA
Posts: 16
IMSlo is on a distinguished road

vacpress it's just too primative for anyone to run except me right now. There is a certain operating sequence that must be followed, if the image has too much detail the outline results in garble etc, etc. etc.

Switcher, thanks for the links but I think I am done with graphics on this project. I can't even think about getting into C# now.

I have just started looking at SQL at first glance it seems to be a booger. I am very familiar with MSAccess and I thought that might help me with SQL. The only thing that Access is helping with is the understanding of tables, queries and relationships.

It appears that the difference between Access and SQL is like the difference Windows and DOS.

My goal is to save the xy coordinates of the pixels in the outline, scale them down to a useable size, sort them in a logical cutting order and write a GCode file.

I thought this would be easier than the graphic manipulation but right now it seems insurmountable. Maybe it will come around.
Tweet this Post!Share on Facebook
Reply With Quote

  #9  
Old 06-14-2006, 11:15 AM
Switcher's Avatar
Moderator
 
Join Date: Apr 2005
Location: Vectorink.com
Posts: 3,659
Blog Entries: 2
Switcher is on a distinguished road

Since you have the outline working, why not just write the X & Y Pixel location to a textbox, send that info to a simple text file, name the files in the order you want them to be cut (file1.txt , file2.txt , file3.txt ...) then call all the sub files to create a complete file.
__________________
Free DXF Files - Vectorink.com - myDXF.blogspot.com
Tweet this Post!Share on Facebook
Reply With Quote

  #10   Ban this user!
Old 06-14-2006, 12:23 PM
 
Join Date: May 2005
Location: USA
Posts: 16
IMSlo is on a distinguished road

Switcher, I'm afraid it's going to be too complicated to do what you suggest. There are a couple of big problems. The first is size (height and width). I will treat these pixel coordinates as units (inches). These could be hundreds high and wide. The way I would handle this is decide how high or wide I wanted the finished product, probably an options on a form, then divide this number by the max x or y. I then would have to multiply all x and y's by the result of this division.

The next is order of the coordinates. The coordinates are generated by starting at y0 x0 scanning in the x direction until max x is reached. When a black pixel is found its location is recorded. The scanning would go to y1 x0 etc until the whole image is scanned. I don't believe the order that comes from scanning will be anywhere close to logical cutting order. I think I must store the coordinates in a place where they can be manipulated before they are exported into a G Code file. Database files are ideal for this type stuff. My problem is that I know nothing about Microsoft SQL database operations and must start at the bottom again. (I had to start at the bottom with VB Net Graphics also to get the outline.) Maybe if I keep digging I will get it. Thanks for the suggestion and interest.
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #11  
Old 06-14-2006, 11:20 PM
Switcher's Avatar
Moderator
 
Join Date: Apr 2005
Location: Vectorink.com
Posts: 3,659
Blog Entries: 2
Switcher is on a distinguished road

Yeah, I know what your talking about ,as far as the graphics. I just started a program with GDI+ (VB .NET 2003). It's not bad though, once you figure out the basics.
__________________
Free DXF Files - Vectorink.com - myDXF.blogspot.com
Tweet this Post!Share on Facebook
Reply With Quote

  #12   Ban this user!
Old 06-14-2006, 11:51 PM
 
Join Date: May 2005
Location: USA
Posts: 16
IMSlo is on a distinguished road

Switcher, I couldn't help but notice that you say you are using VB.NET 2003. You probably know that Microsoft is giving away VB.NET 2005 Express, or at least were a few months ago. I don't know if there's much difference in the 2 but I always like to have the latest version of any free software.
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





All times are GMT -5. The time now is 03:40 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