outline from gadient mask

  • 226 Replies
  • 78833 Views
*

yotamarker

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1003
  • battle programmer
    • battle programming
Re: outline from gadient mask
« Reply #180 on: September 28, 2017, 07:55:09 pm »

*

Korrelan

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1454
  • Look into my eyes! WOAH!
    • YouTube
Re: outline from gadient mask
« Reply #181 on: September 30, 2017, 01:53:29 pm »
If you switch to a HSL colour model you will find it easier to group/ differentiate skin tones etc.

At the bottom of the video is a colour analysis window showing the entire colour pallet for that image.  Rather than RGB it converts the pallet into a 360 range on the x axis, with brightness on the Y axis.



 :)
It thunk... therefore it is!...    /    Project Page    /    KorrTecx Website

*

keghn

  • Trusty Member
  • *********
  • Terminator
  • *
  • 824
Re: outline from gadient mask
« Reply #182 on: September 30, 2017, 05:51:48 pm »
 Outline can be unraveled. Two outlines can be compared with DTW. 
How DTW (Dynamic Time Warping) algorithm works: 

 



*

keghn

  • Trusty Member
  • *********
  • Terminator
  • *
  • 824
Re: outline from gadient mask
« Reply #183 on: September 30, 2017, 06:53:59 pm »

Extracting Optimal Performance from Dynamic Time Warping: 

http://www.cs.unm.edu/~mueen/DTW.pdf


*

yotamarker

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1003
  • battle programmer
    • battle programming
Re: outline from gadient mask
« Reply #184 on: September 30, 2017, 10:05:13 pm »

group/ differentiate skin tones ?

Rather than RGB it converts the pallet into a 360 range on the x axis, with brightness on the Y axis ?
how did you get from that to boxing the objects so fast ?

also, this is the 1st video of yours I see with all the objects in the image boxed, I'm very intrigued to see  the algorithm walkthrough.

*

Korrelan

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1454
  • Look into my eyes! WOAH!
    • YouTube
Re: outline from gadient mask
« Reply #185 on: September 30, 2017, 11:46:18 pm »
I’m pretty sure I posted this video months ago when you first started writing your bounding box routines.  It was part of my explanation that finding object boundaries against a plain back ground was easy, the problems arise when trying to find boundaries amongst complex backgrounds; tree leaves I believe at the time. I re-posted it to show the HSL pallet usage.

RGB to HSL conversion is very easy.

https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion

Quote
how did you get from that to boxing the objects so fast ?

The colour model has no bearing on the speed of the algorithm that detects the boundaries.  The HSL colour model just allows you to select colour groups (ie skin tones) easier.  These algorithms are not running especially ‘fast’, I wrote them in VB6 basic for ease.

Quote
I'm very intrigued to see the algorithm walkthrough.

The basic idea I used was to scan each pixel and note its colour; if the colour was different from the background then I created a bounding box in an array.  If the next pixel was within a set bias (colour distance) of the first pixel then I expanded the box to include it, else I created a new box with its own colour. As each pixel is scanned it is checked against the list of bounding boxes within its proximity; if the colour range is similar it’s added and the box expanded.

I’ll post the complete (un-optimized) code… it’s very similar to VB.NET so you should follow it easily.  This does not use HSL just difference from back ground as in the example video.

Any antiquated coding techniques are because I understand how the complier optimizes code; its basically the most efficient representation before the complier parses the code.

Code

    '// Auto define bounding boxes
   
    '// check each pixels x,y to see if its within the bounds of a box
    '// if it is then expand the box to include the pixel
    '// else start a new box
   
    Dim BOX(10000, 10) As Long
    Dim tnb As Long
   
    bias = 2
 
    '// sum colour instances
    For Y = 0 To Picture2.ScaleHeight - 1
        For X = 0 To Picture2.ScaleWidth - 1
         
            '// get the colour
            RR = ImageData(2, X, Y)
            GG = ImageData(1, X, Y)
            BB = ImageData(0, X, Y)
                   
            '// check for colour other than BLACK
            cfnd = 0
            If RR > 50 Then cfnd = 1
            If GG > 50 Then cfnd = 1
            If BB > 50 Then cfnd = 1
           
            bfnd = 0
            If cfnd Then
               
                '// check if inside existing bounding box
                For dd = 1 To tnb
                    bl = 0
                    If X > BOX(dd, 1) - bias Then bl = bl + 1
                    If X < BOX(dd, 3) + bias Then bl = bl + 1
                    If Y > BOX(dd, 2) - bias Then bl = bl + 1
                    If Y < BOX(dd, 4) + bias Then bl = bl + 1
                    If bl = 4 Then bfnd = dd: Exit For
                Next
                       
                If bfnd Then
                    '// Adjust existing box
                    If X < BOX(bfnd, 1) Then BOX(bfnd, 1) = X
                    If X > BOX(bfnd, 3) Then BOX(bfnd, 3) = X
                    If Y < BOX(bfnd, 2) Then BOX(bfnd, 2) = Y
                    If Y > BOX(bfnd, 4) Then BOX(bfnd, 4) = Y
                Else
                    '// Create new box
                    tnb = tnb + 1
                    BOX(tnb, 1) = X
                    BOX(tnb, 2) = Y
                    BOX(tnb, 3) = X
                    BOX(tnb, 4) = Y
                End If
           
            End If
        Next
    Next
 
    '// remove small boxes inside larger boxes
    For e = 1 To tnb
   
        bx = BOX(e, 1) + ((BOX(e, 3) - BOX(e, 1)) / 2)
        By = BOX(e, 2) + ((BOX(e, 4) - BOX(e, 2)) / 2)
       
        For dd = 1 To tnb
            bbw = 0
            fnd = 0
                 
            If BOX(e, 1) >= BOX(dd, 1) Then
                If BOX(e, 1) <= BOX(dd, 3) Then
                    If BOX(e, 2) >= BOX(dd, 2) Then
                        If BOX(e, 2) <= BOX(dd, 4) Then fnd = 1
                    End If
                End If
            End If
            If BOX(e, 3) >= BOX(dd, 1) Then
                If BOX(e, 3) <= BOX(dd, 3) Then
                    If BOX(e, 2) >= BOX(dd, 2) Then
                        If BOX(e, 2) <= BOX(dd, 4) Then fnd = 1
                    End If
                End If
            End If
            If BOX(e, 1) >= BOX(dd, 1) Then
                If BOX(e, 1) <= BOX(dd, 3) Then
                    If BOX(e, 4) >= BOX(dd, 2) Then
                        If BOX(e, 4) <= BOX(dd, 4) Then fnd = 1
                    End If
                End If
            End If
            If BOX(e, 3) >= BOX(dd, 1) Then
                If BOX(e, 3) <= BOX(dd, 3) Then
                    If BOX(e, 4) >= BOX(dd, 2) Then
                        If BOX(e, 4) <= BOX(dd, 4) Then fnd = 1
                    End If
                End If
            End If
            '
            If fnd = 1 Then
               
                If BOX(e, 1) < BOX(dd, 1) Then BOX(dd, 1) = BOX(e, 1)
                If BOX(e, 3) > BOX(dd, 3) Then BOX(dd, 3) = BOX(e, 3)
                If BOX(e, 2) < BOX(dd, 2) Then BOX(dd, 2) = BOX(e, 2)
                If BOX(e, 4) > BOX(dd, 4) Then BOX(dd, 4) = BOX(e, 4)
               
                BOX(dd, 5) = 1: Exit For
            End If
         
        Next
    Next
   
jump3:
   
    '// plot boxes
    Picture2.AutoRedraw = False
    For dd = 1 To tnb
        If BOX(dd, 5) Then
            x1 = BOX(dd, 1)
            x2 = BOX(dd, 3)
            y1 = BOX(dd, 2)
            y2 = BOX(dd, 4)
            Picture2.Line (x1, y1)-(x2, y2), &HFF0000, B
        End If
    Next
    Picture2.AutoRedraw = True


 :)
It thunk... therefore it is!...    /    Project Page    /    KorrTecx Website

*

yotamarker

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1003
  • battle programmer
    • battle programming
Re: outline from gadient mask
« Reply #186 on: October 01, 2017, 04:06:48 pm »
at the moment I can't understand how your code works (at all) but from your description it sounds like some sort of a blob
that inflates around the objects

*

yotamarker

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1003
  • battle programmer
    • battle programming
Re: outline from gadient mask
« Reply #187 on: October 05, 2017, 05:07:17 pm »

*

yotamarker

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1003
  • battle programmer
    • battle programming
Re: outline from gadient mask
« Reply #188 on: October 05, 2017, 05:10:06 pm »

*

yotamarker

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1003
  • battle programmer
    • battle programming
Re: outline from gadient mask
« Reply #189 on: October 06, 2017, 10:21:10 pm »

*

yotamarker

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1003
  • battle programmer
    • battle programming
Re: outline from gadient mask
« Reply #190 on: October 06, 2017, 10:25:45 pm »
tip :
arrays can be used in functions without passing their dimensions, by calling them object :

Code
Private Function markPixelMatrix(ByVal bmp As Bitmap, ByVal objectList As Object) As Bitmap
            For i = 0 To bmp.Height - 1
                For j = 0 To bmp.Width - 1
                    If objectList(j, i) Then
                        bmp = Aeye.mark_dark_pixelRED(j, i, bmp, 1)
                    End If
                Next
            Next
            Return bmp
        End Function

*

yotamarker

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1003
  • battle programmer
    • battle programming
Re: outline from gadient mask
« Reply #191 on: October 13, 2017, 10:03:42 pm »
what are the common image attributes you suggest putting in Neural Network hidden layers for image recognition classifiers ?
corners, colors, ...

*

yotamarker

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1003
  • battle programmer
    • battle programming
Re: outline from gadient mask
« Reply #192 on: October 13, 2017, 10:10:13 pm »
also are the NN node(circle) values weight and intensity ? is there something additional ? 

*

keghn

  • Trusty Member
  • *********
  • Terminator
  • *
  • 824
Re: outline from gadient mask
« Reply #193 on: October 14, 2017, 04:35:42 pm »
 For the neurons you also need the squashing function and bias for a complete artificial neuron.

*

ivan.moony

  • Trusty Member
  • ************
  • Bishop
  • *
  • 1729
    • mind-child
Re: outline from gadient mask
« Reply #194 on: October 14, 2017, 05:26:30 pm »
For image attributes, people are using short beveled feature lines and circles. On https://deeplearning4j.org/neuralnet-overview you can see those if you scroll down a bit.

 


Requirements for functional equivalence to conscious processing?
by DaltonG (General AI Discussion)
November 19, 2024, 11:56:05 am
Will LLMs ever learn what is ... is?
by HS (Future of AI)
November 10, 2024, 06:28:10 pm
Who's the AI?
by frankinstien (Future of AI)
November 04, 2024, 05:45:05 am
Project Acuitas
by WriterOfMinds (General Project Discussion)
October 27, 2024, 09:17:10 pm
Ai improving AI
by infurl (AI Programming)
October 19, 2024, 03:43:29 am
Atronach's Eye
by WriterOfMinds (Home Made Robots)
October 13, 2024, 09:52:42 pm
Running local AI models
by spydaz (AI Programming)
October 07, 2024, 09:00:53 am
Hi IM BAA---AAACK!!
by MagnusWootton (Home Made Robots)
September 16, 2024, 09:49:10 pm
LLaMA2 Meta's chatbot released
by spydaz (AI News )
August 24, 2024, 02:58:36 pm
ollama and llama3
by spydaz (AI News )
August 24, 2024, 02:55:13 pm
AI controlled F-16, for real!
by frankinstien (AI News )
June 15, 2024, 05:40:28 am
Open AI GPT-4o - audio, vision, text combined reasoning
by MikeB (AI News )
May 14, 2024, 05:46:48 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am

Users Online

402 Guests, 0 Users

Most Online Today: 532. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles