outline from gadient mask

  • 130 Replies
  • 4178 Views
*

keghn

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 399
Re: outline from gadient mask
« Reply #120 on: May 23, 2017, 02:21:51 pm »
 Another way of doing curved lines is curved ratios. That is curve length divided by the chord:  Or curve BX divided by chord BX:

https://en.wikipedia.org/wiki/File:Chord_in_mathematics.svg



https://en.wikipedia.org/wiki/Chord_(aeronautics)

https://en.wikipedia.org/wiki/Chord_(geometry)

*

yotamarker

  • Replicant
  • ********
  • 509
Re: outline from gadient mask
« Reply #121 on: May 26, 2017, 10:01:54 pm »

this is just the overlap alg
I used a sobel alg filter first, then the dijkstra alg and a combo of isoutline, is dark pixel.
1600X2000 pixels is kinda the maximum it can handle, it is a bit slow I have some around it ideas, to speed up.
suggestions ?

*

keghn

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 399
Re: outline from gadient mask
« Reply #122 on: May 28, 2017, 08:48:36 pm »
Intro to Algorithms: Crash Course Computer Science #13: 


*

yotamarker

  • Replicant
  • ********
  • 509
Re: outline from gadient mask
« Reply #123 on: May 28, 2017, 09:38:40 pm »
I'm pretty sure keghn is a chatbot, one of the advanced out there.
the prev vid was a waste of time and is not related to this thread, and I'm telling this the the keghn software coder.

*

keghn

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 399
Re: outline from gadient mask
« Reply #124 on: May 29, 2017, 01:43:39 am »
  Sorry. But i like how Carrie explained the dijkstra algorithm. And compared it to the other algorithms.

*

yotamarker

  • Replicant
  • ********
  • 509
Re: outline from gadient mask
« Reply #125 on: May 30, 2017, 01:55:29 pm »
would a stronger computer result in the algorithm running faster ?

*

korrelan

  • Trusty Member
  • ********
  • Replicant
  • *
  • 608
  • Look into my eyes! WOAH!
    • Google +

*

keghn

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 399
Re: outline from gadient mask
« Reply #127 on: May 31, 2017, 07:03:06 pm »
 Does your program move the image into memory and then do everything to it.
 Or do you do one thing save it back to hard drive. Then select a different operation load it back into memory and
when finished save it back to hard drive and then repeat? Accessing the hard drive all the time will slow thing down.
 If you like doing that way may have to use a ram disc software.

 Load once, then do all you algorithms in memory and save into a matrixes in memory, A mat.

 Another speed up is to print all you,  trouble shooting , debug information data, to the screen last and
also saves to the hard drive as the last part. Printing out information during the building and testing the program is all right. But when it is finished they should be removed. Printing text to the screen can really slow down a program.



*

korrelan

  • Trusty Member
  • ********
  • Replicant
  • *
  • 608
  • Look into my eyes! WOAH!
    • Google +
Re: outline from gadient mask
« Reply #128 on: June 01, 2017, 10:20:46 am »
As keghn said…

You need to profile and optimize your code. 

VB.NET is an interpreted language; it has no native compiler etc so it’s not the fastest language by a long mark.  You could use another faster language; even JAVA is generally faster than VB.NET but preferably something like C++.

https://adtmag.com/articles/2002/08/01/speed-up-your-vbnet-code.aspx

https://msdn.microsoft.com/en-us/library/aa289513(v=vs.71).aspx

There are loads of web sites offering information on code optimization for specific languages but there are some basic rules that apply to all languages.

Make sure you are declaring the best/ fastest variable types for each purpose.
Check you are passing the correct variable types to subs/ functions.
Some built in functions can be very easy to use but very slow.
Remove as much math/ code from the inside of loops as possible.
Use pre-calculated ‘look up’ tables/ arrays where ever possible to avoid complex math.
Check your loops are not over running.
Limit sub calls they are usually very slow, use in-line code where possible.
Avoid/ limit classes; these are again very easy to use but very slow.
Re-think your algorithms… is there a faster way?
Etc…

Avoid using multiple comparisons in an IF statement on the same line; most compilers will check every comparison even if the first one is not matched.

.If xPos > 0 And xPos < image.Width - 1 And Ypos > 0 And Ypos < image.Height - 1 Then

Nest these into separate IF’s… I know it makes your code longer but it also makes it faster.

Remove unnecessary calculations from within your loops... ie...

Code: [Select]
        Public Shared Function mark_dark_pixel(ByVal x As Integer, ByVal y As Integer, ByVal bmp1 As Bitmap, ByVal marker As Byte)

            For i As Integer = 0 To marker

                yi=y+i  <<<<<<<<<

For j As Integer = 0 To marker
                    Try
                        bmp1.SetPixel(x + j, yi, Color.Green)
                    Catch ex As Exception

                    End Try
                Next
            Next
            Return bmp1

        End Function

Write small test programs where you can accurately time methods and functions against each other inside a set loop size to find the fastest coding schema.  Use an accurate timer to time loops and print the results so you can see which sections are slowing your code down… then optimize those sections.

Code optimization can often take longer than the actual code production and it’s a good habit to optimize as you go along once you are familiar with the bottlenecks and foibles of your chosen language.

I personally really enjoy code profiling.

 :)
« Last Edit: June 01, 2017, 12:19:10 pm by korrelan »
It thunk... therefore it is!

*

keghn

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 399
Re: outline from gadient mask
« Reply #129 on: June 10, 2017, 07:06:26 pm »
Gauss's magic shoelace area formula and its calculus companion: 


*

yotamarker

  • Replicant
  • ********
  • 509
Re: outline from gadient mask
« Reply #130 on: June 11, 2017, 10:41:00 pm »

 


Users Online

33 Guests, 1 User
Users active in past 15 minutes:
ivan.moony
[Trusty Member]

Most Online Today: 69. Most Online Ever: 208 (August 27, 2008, 09:36:30 am)

Articles