Ai Dreams Forum

Artificial Intelligence => General AI Discussion => Topic started by: yotamarker on March 31, 2017, 04:15:38 am

Title: outline from gadient mask
Post by: yotamarker on March 31, 2017, 04:15:38 am
I'm looking for an alg to know if a pixel is an outline pixel based on the pixels around it.
Title: Re: outline from gadient mask
Post by: korrelan on March 31, 2017, 11:11:06 am
Quote
I'm looking for an alg to know if a pixel is an outline pixel based on the pixels around it.

So… a image convolution filter?

There are several methods of obtaining a shape outline from an image and loads of pre-written libraries available.

https://en.wikipedia.org/wiki/Outline_of_object_recognition (https://en.wikipedia.org/wiki/Outline_of_object_recognition)

I wrote my own adaptive convolution routines for extracting object boundaries from images.  The main idea is to use colour contrast NOT pixel brightness.  Simply break the image into its RGB components and detect the colour boundaries. 

(http://i.imgur.com/Zl5G18U.jpg)

The image in the center is using brightness as the bias; as you can see the light/ brightness variation causes contours.  Bottom left is the same routine using colour contrast… much better.

Check each pixel with its adjacent RGB values.  If there is a difference within a set bias mark as an outline point/ pixel.

.bias=20
.red = red value of pixel your checking
.ored = red value of adjacent pixel
.If red > ored –bias and red < ored+bias then change=change+1
.do same for green & blue
.if change=3 then draw outline pixel else don’t

I’m not preaching but the best way to understand/ learn this kind of simple stuff is to experiment with your own code. Using someone else’s pre-written routines rarely gives the desired results.


 :)
Title: Re: outline from gadient mask
Post by: yotamarker on March 31, 2017, 02:20:33 pm
that's exactly what i'm talking about but I don't understand what you mean by adjacent pixel
each pixel is surrounded by 8 other pixels
Title: Re: outline from gadient mask
Post by: yotamarker on March 31, 2017, 02:57:47 pm
so I implemented your alg but something is missing.

method in aeye class :
Code: [Select]
  Public Shared Function isOutLine(ByVal xPos As Integer, ByVal Ypos As Integer, ByVal image As Bitmap, ByVal bias As Integer) As Boolean

        Dim result As Boolean = False
        Dim change As Byte = 0
        If xPos > 0 And xPos < image.Width - 1 And Ypos > 0 And Ypos < image.Height - 1 Then
            Dim color1, color2, color3, color4, color5, color6, color7, color8, color9 As Color
            color1 = image.GetPixel(xPos - 1, Ypos - 1)
            color2 = image.GetPixel(xPos, Ypos - 1)
            color3 = image.GetPixel(xPos + 1, Ypos - 1)
            color7 = image.GetPixel(xPos - 1, Ypos + 1)
            color8 = image.GetPixel(xPos, Ypos + 1)
            color9 = image.GetPixel(xPos + 1, Ypos + 1)
            color4 = image.GetPixel(xPos - 1, Ypos)
            color6 = image.GetPixel(xPos + 1, Ypos)
            color5 = image.GetPixel(xPos, Ypos)

            If (CType(color5.R, Integer) > CType(color4.R, Integer) - bias) And (CType(color5.R, Integer) < CType(color4.R, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.G, Integer) > CType(color4.G, Integer) - bias) And (CType(color5.G, Integer) < CType(color4.G, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.B, Integer) > CType(color4.B, Integer) - bias) And (CType(color5.B, Integer) < CType(color4.B, Integer) + bias) Then
                change += 1

            End If
        End If

        'Dim sumR, sumG, sumB As Integer

        'sumR = (CType(color1.R, Integer) + CType(color2.R, Integer) + CType(color3.R, Integer))
        'sumR -= (CType(color7.R, Integer) + CType(color8.R, Integer) + CType(color9.R, Integer))
        ''sumG = (CType(color7.R, Integer) + CType(color8.R, Integer) + CType(color9.R, Integer))
        ''sumG -= (CType(color1.G, Integer) + CType(color2.G, Integer) + CType(color3.G, Integer))
        ''sumB = (CType(color1.B, Integer) + CType(color2.B, Integer) + CType(color3.B, Integer))
        ''sumB -= (CType(color7.B, Integer) + CType(color8.B, Integer) + CType(color9.B, Integer))
        'sumR = Abs(sumR)
        ''sumG = Abs(sumG)
        ''sumB = Abs(sumB)
        ''Dim sumR2, sumG2, sumB2 As Integer
        ''sumR2 = (CType(color1.R, Integer) + CType(color4.R, Integer) + CType(color7.R, Integer))
        ''sumG2 = (CType(color1.G, Integer) + CType(color4.G, Integer) + CType(color7.G, Integer))
        ''sumB2 = (CType(color1.B, Integer) + CType(color4.B, Integer) + CType(color7.B, Integer))
        ''sumR2 -= (CType(color3.R, Integer) + CType(color6.R, Integer) + CType(color9.R, Integer))
        ''sumG2 -= (CType(color3.G, Integer) + CType(color6.G, Integer) + CType(color9.G, Integer))
        ''sumB2 -= (CType(color3.B, Integer) + CType(color6.B, Integer) + CType(color9.B, Integer))
        ''sumR2 = Abs(sumR2)
        ''sumG2 = Abs(sumG2)
        ''sumB2 = Abs(sumB2)

        ''sumR2 = color1.R + color4.R + color7.R
        ''sumG2 = color1.G + color4.G + color7.G
        ''sumB2 = color1.B + color4.B + color7.B
        ''sumR2 -= color3.R + color6.R + color9.R
        ''sumG2 -= color3.G + color6.G + color9.G
        ''sumB2 -= color3.B + color6.B + color9.B
        If change = 3 Then
            result = True
        End If
        Return result
    End Function

button click event main code :
Code: [Select]
Imports System.Math
Public Class Form1
    Dim eye1 As New Aeye()
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim bmp As New Bitmap("c:\testimage\x1.bmp")
        Dim bmp2 As Bitmap = bmp.Clone()
        PictureBox1.Image = bmp.Clone()

        For i = 1 To bmp.Height - 2
            For j = 1 To bmp.Width - 2
                If Not Aeye.isOutLine(j, i, bmp, 20) Then
                    bmp2 = Aeye.mark_dark_pixel(j, i, bmp2, 1)
                End If






            Next
        Next

        PictureBox2.Image = bmp2.Clone()

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim bmp As New Bitmap("c:\testimage\x1.bmp")
        PictureBox1.Image = bmp.Clone()
    End Sub
End Class

result :
(https://i.imgflip.com/1mfvv2.jpg) (https://imgflip.com/i/1mfvv2) (https://imgflip.com/memegenerator)
Title: Re: outline from gadient mask
Post by: keghn on March 31, 2017, 03:11:38 pm
https://en.wikipedia.org/wiki/Canny_edge_detector


 Or:

https://en.wikipedia.org/wiki/Sobel_operator
Title: Re: outline from gadient mask
Post by: korrelan on March 31, 2017, 03:16:10 pm
That was just meant to give you the basic idea lol.

If you are reading the RGB value left to right, bottom to top you need to check the pixel either above or below also.

So check color8.r against the target color5.r pixel also. (rgb)

.if change=6 then draw outline pixel else don’t

Also you are not checking between bias…

.If red > ored –bias and red < ored+bias then change=change+1

Also make sure your working in pixel scales not twips etc.

Also you don’t really need the rest of the pixel variables if your not going to use them.

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on March 31, 2017, 03:44:56 pm
it is working thank you very much.
Code: [Select]
Public Shared Function isOutLine(ByVal xPos As Integer, ByVal Ypos As Integer, ByVal image As Bitmap, ByVal bias As Integer) As Boolean

        Dim result As Boolean = False
        Dim change As Byte = 0
        If xPos > 0 And xPos < image.Width - 1 And Ypos > 0 And Ypos < image.Height - 1 Then
            Dim color1, color2, color3, color4, color5, color6, color7, color8, color9 As Color
            color1 = image.GetPixel(xPos - 1, Ypos - 1)
            color2 = image.GetPixel(xPos, Ypos - 1)
            color3 = image.GetPixel(xPos + 1, Ypos - 1)
            color7 = image.GetPixel(xPos - 1, Ypos + 1)
            color8 = image.GetPixel(xPos, Ypos + 1)
            color9 = image.GetPixel(xPos + 1, Ypos + 1)
            color4 = image.GetPixel(xPos - 1, Ypos)
            color6 = image.GetPixel(xPos + 1, Ypos)
            color5 = image.GetPixel(xPos, Ypos)

            If (CType(color5.R, Integer) > CType(color4.R, Integer) - bias) And (CType(color5.R, Integer) < CType(color4.R, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.G, Integer) > CType(color4.G, Integer) - bias) And (CType(color5.G, Integer) < CType(color4.G, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.B, Integer) > CType(color4.B, Integer) - bias) And (CType(color5.B, Integer) < CType(color4.B, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.R, Integer) > CType(color8.R, Integer) - bias) And (CType(color5.R, Integer) < CType(color8.R, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.G, Integer) > CType(color8.G, Integer) - bias) And (CType(color5.G, Integer) < CType(color8.G, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.B, Integer) > CType(color8.B, Integer) - bias) And (CType(color5.B, Integer) < CType(color8.B, Integer) + bias) Then
                change += 1

            End If
        End If

        'Dim sumR, sumG, sumB As Integer

        'sumR = (CType(color1.R, Integer) + CType(color2.R, Integer) + CType(color3.R, Integer))
        'sumR -= (CType(color7.R, Integer) + CType(color8.R, Integer) + CType(color9.R, Integer))
        ''sumG = (CType(color7.R, Integer) + CType(color8.R, Integer) + CType(color9.R, Integer))
        ''sumG -= (CType(color1.G, Integer) + CType(color2.G, Integer) + CType(color3.G, Integer))
        ''sumB = (CType(color1.B, Integer) + CType(color2.B, Integer) + CType(color3.B, Integer))
        ''sumB -= (CType(color7.B, Integer) + CType(color8.B, Integer) + CType(color9.B, Integer))
        'sumR = Abs(sumR)
        ''sumG = Abs(sumG)
        ''sumB = Abs(sumB)
        ''Dim sumR2, sumG2, sumB2 As Integer
        ''sumR2 = (CType(color1.R, Integer) + CType(color4.R, Integer) + CType(color7.R, Integer))
        ''sumG2 = (CType(color1.G, Integer) + CType(color4.G, Integer) + CType(color7.G, Integer))
        ''sumB2 = (CType(color1.B, Integer) + CType(color4.B, Integer) + CType(color7.B, Integer))
        ''sumR2 -= (CType(color3.R, Integer) + CType(color6.R, Integer) + CType(color9.R, Integer))
        ''sumG2 -= (CType(color3.G, Integer) + CType(color6.G, Integer) + CType(color9.G, Integer))
        ''sumB2 -= (CType(color3.B, Integer) + CType(color6.B, Integer) + CType(color9.B, Integer))
        ''sumR2 = Abs(sumR2)
        ''sumG2 = Abs(sumG2)
        ''sumB2 = Abs(sumB2)

        ''sumR2 = color1.R + color4.R + color7.R
        ''sumG2 = color1.G + color4.G + color7.G
        ''sumB2 = color1.B + color4.B + color7.B
        ''sumR2 -= color3.R + color6.R + color9.R
        ''sumG2 -= color3.G + color6.G + color9.G
        ''sumB2 -= color3.B + color6.B + color9.B
        If change = 6 Then
            result = True
        End If
        Return result
    End Function

I'll delete the unused variables also.
Title: Re: outline from gadient mask
Post by: korrelan on March 31, 2017, 10:16:48 pm
@yot

You are welcome.

@keghn

I agree both are very good algorithms and well worth exploring/ learning.

I presumed yot was new to this type of coding, and I’m sure you’ll agree… programming should be fun… and I think it’s important to understand exactly what the code does and how it does it.  Using someone else’s library doesn't quite achieve that.

Now I need to read the top of the thread to figure out why yot needs to find the perimeter of a triangle lol.

 :)
Title: Re: outline from gadient mask
Post by: keghn on April 01, 2017, 12:21:17 am
 I do not use the common edge detectors to find lines. I use XNOR logic: 

https://techcrunch.com/2017/01/19/xnor-ai-frees-ai-from-the-prison-of-the-supercomputer/
Title: Re: outline from gadient mask
Post by: yotamarker on April 01, 2017, 09:50:17 am
now I need to get the images objects bounds
https://www.youtube.com/watch?v=5m3_2C8xrFI&t=204s (https://www.youtube.com/watch?v=5m3_2C8xrFI&t=204s)

I used a recursive function to trace the objects, but it just glitches a lot with stack
overflows and out of range exceptions. so I'm looking for another algorithm.
Title: Re: outline from gadient mask
Post by: korrelan on April 01, 2017, 12:39:28 pm
Oh! Now I understand what you’re trying to do. 

You are trying to follow the objects perimeter to define a bounding box around each object in the image; I presume you are then going to try and recognise the objects within the boxes… nah! That isn’t going to work on complex scenes.

Your program is crashing because of your array limits; you only allowed 1000 bounding boxes.  There are loads of problems with this approach to object recognition; besides your routine detecting the JPG compression anomalies in your selected image (bad image choice) defining the outline of a single object is practically impossible.  Without extra information from stereo cameras or depth sensors you will never find the perimeter of an object in a video feed for example.

(http://i.imgur.com/olwtosa.jpg)

There are other methods like blobbing that can find the center of ‘mass’ of a block of colour but most objects are composed of more than one colour. You can blob and then run an outline routine etc… there are so many options/ methods. 

https://en.wikipedia.org/wiki/Blob_detection (https://en.wikipedia.org/wiki/Blob_detection)

Then you have to consider things like scale and rotational invariance of objects. 

https://en.wikipedia.org/wiki/Scale_invariance (https://en.wikipedia.org/wiki/Scale_invariance)

As usual this is a huge complex topic that often requires a custom solution.

A better method/ approach is to use feature detection. 

At its simplest this could mean selecting a ten pixel square section of the image you are wanting to recognise and storing it with a name.  Then scan any selected image for the saved section; chances of finding the exact same block in another image are pretty slim; especially if you select a feature unique to the image.  This technique is used for finding smiling faces in pictures etc; using eigenface templates.

https://en.wikipedia.org/wiki/Eigenface (https://en.wikipedia.org/wiki/Eigenface)

This of course is the main technique used in convolutional networks, the image is searched with millions of smaller images of known features… both the image to be searched and the feature image set are run through a convolutional filter to highlight a specific property, lines, contrast gradients etc.

The list of methods and techniques is endless… enjoy learning.

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 01, 2017, 02:23:22 pm
why isn’t it going to work on complex scenes ? I wont be chekin each pixel in the range
just about 8x8 and the corners before that.
Title: Re: outline from gadient mask
Post by: yotamarker on April 01, 2017, 02:26:08 pm
@keghn  that xnor ai link, no doubt they created something cool but, it is useless to me cause it has no algorithms or walkthroughs
Title: Re: outline from gadient mask
Post by: korrelan on April 01, 2017, 02:37:29 pm
http://cvgl.stanford.edu/projects/3DVP/ (http://cvgl.stanford.edu/projects/3DVP/)

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 01, 2017, 02:46:54 pm
they should use videos for the recognition not analyze the juice out of images
Title: Re: outline from gadient mask
Post by: keghn on April 01, 2017, 02:59:19 pm
 @YotomMaker. XNor is about breaking a image up into a grid of squares, in a quad tree fashion is ok. Then compare
average color or grey scale to each other square. Using XOR logic to compare adjacent  squares.  If they are not equal then there is a line between them.
 If not they are the same blob. Once you change a image to lines then you can convert them into chain code,

 Finding the contours: 

http://answers.opencv.org/question/88501/how-to-classify-chain-codes/ (http://answers.opencv.org/question/88501/how-to-classify-chain-codes/)

https://pdfs.semanticscholar.org/eb33/e3215bf023d4e8b1dbcaae37bbfb7ae5e3cc.pdf (https://pdfs.semanticscholar.org/eb33/e3215bf023d4e8b1dbcaae37bbfb7ae5e3cc.pdf)

https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm (https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm)

https://www.youtube.com/watch?v=TS_WFAVeHuI (https://www.youtube.com/watch?v=TS_WFAVeHuI)
Title: Re: outline from gadient mask
Post by: yotamarker on April 01, 2017, 05:04:28 pm
maybe you can figure it out
Code: [Select]
Imports System.Math
Imports WindowsApp1.rinegan

Public Class Form1
    Dim eye1 As New Aeye()
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim bmp As New Bitmap("c:\testimage\x1.bmp")
        Dim bmp2 As Bitmap = bmp.Clone()
        PictureBox1.Image = bmp.Clone()

        Dim imageMatrix(bmp.Width, bmp.Height) As Boolean
        Dim hx As New List(Of Integer)
        Dim lx As New List(Of Integer)
        Dim hy As New List(Of Integer)
        Dim ly As New List(Of Integer)
        hx.Add(0)
        hy.Add(0)
        lx.Add(bmp.Width)
        ly.Add(bmp.Height)

        Dim bounderArray(3000) As List(Of Point)
        Dim bounderArrayindex As Integer = 0

        bounderArray(bounderArrayindex) = New List(Of Point)
        bounderArray(bounderArrayindex).Add(New Point(0, 0))
        For i = 1 To bmp.Height - 2
            For j = 1 To bmp.Width - 2
                imageMatrix(j, i) = Not Aeye.isOutLine(j, i, bmp, 20)
                If imageMatrix(j, i) Then
                    bmp2 = Aeye.mark_dark_pixel(j, i, bmp2, 1)
                    If Not imageMatrix(j - 1, i) And Not imageMatrix(j, i - 1) Then 'new outline point
                        bounderArrayindex += 1
                        bounderArray(bounderArrayindex) = New List(Of Point)
                        bounderArray(bounderArrayindex).Add(New Point(j, i))

                        hx.Add(0)
                        hy.Add(0)
                        lx.Add(bmp.Width)
                        ly.Add(bmp.Height)
                        Aeye.maxer(j, hx(bounderArrayindex))
                        Aeye.maxer(i, hy(bounderArrayindex))
                        Aeye.miner(j, lx(bounderArrayindex))
                        Aeye.miner(i, ly(bounderArrayindex))

                    ElseIf imageMatrix(j, i - 1) Then
                        For index = 0 To bounderArrayindex
                            If bounderArray(index).Contains(New Point(j, i - 1)) Then
                                bounderArray(index).Add(New Point(j, i))
                                Aeye.maxer(j, hx(bounderArrayindex))
                                Aeye.maxer(i, hy(bounderArrayindex))
                                Aeye.miner(j, lx(bounderArrayindex))
                                Aeye.miner(i, ly(bounderArrayindex))
                                Exit For
                            End If
                        Next
                    Else
                        For index = 0 To bounderArrayindex
                            If bounderArray(index).Contains(New Point(j, i - 1)) Then
                                bounderArray(index).Add(New Point(j, i))
                                Aeye.maxer(j, hx(bounderArrayindex))
                                Aeye.maxer(i, hy(bounderArrayindex))
                                Aeye.miner(j, lx(bounderArrayindex))
                                Aeye.miner(i, ly(bounderArrayindex))
                                Exit For
                            End If
                        Next
                    End If
                End If
            Next
        Next

        For index = 0 To bounderArrayindex
            bmp = Aeye.graphicContour(bmp, lx(index), hx(index), ly(index), hy(index))
        Next
        PictureBox2.Image = bmp.Clone()

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim bmp As New Bitmap("c:\testimage\x1.bmp")
        PictureBox1.Image = bmp.Clone()
    End Sub
End Class
Title: Re: outline from gadient mask
Post by: yotamarker on April 01, 2017, 06:18:05 pm
here is the class with the tracer how come it only works 4 simple shapes is beyond me

Code: [Select]
Imports System.Math
Public Class Aeye
    Public outlinePixel As Integer = 30
    Dim Imageslist As New List(Of ImageList)
    Dim ImageListCounter As Integer = 0
    Dim minX, minY, maxX, maxY As Integer
    Dim checkedMatrix(1000, 1000) As Boolean
    Dim imageMatrix(1000, 1000) As Boolean
    Dim HX(1000) As Integer
    Dim LX(1000) As Integer
    Dim HY(1000) As Integer
    Dim LY(1000) As Integer
    Dim Icounter As Integer
    Public Shared Function is_pixel_dark_at(ByVal xPos As Integer, ByVal Ypos As Integer, ByVal image As Bitmap, ByVal DarkPixel As Integer) As Boolean
        Dim color As Color
        Dim r, g, b As Integer
        color = image.GetPixel(xPos, Ypos)
        r = color.R
        g = color.G
        b = color.B
        If (r < DarkPixel) And (g < DarkPixel) And (b < DarkPixel) Then
            Return True
        Else
            Return False
        End If
    End Function
    Public Shared Function isOutLine(ByVal xPos As Integer, ByVal Ypos As Integer, ByVal image As Bitmap, ByVal bias As Integer) As Boolean

        Dim result As Boolean = False
        Dim change As Byte = 0
        If xPos > 0 And xPos < image.Width - 1 And Ypos > 0 And Ypos < image.Height - 1 Then
            Dim color1, color2, color3, color4, color5, color6, color7, color8, color9 As Color
            color1 = image.GetPixel(xPos - 1, Ypos - 1)
            color2 = image.GetPixel(xPos, Ypos - 1)
            color3 = image.GetPixel(xPos + 1, Ypos - 1)
            color7 = image.GetPixel(xPos - 1, Ypos + 1)
            color8 = image.GetPixel(xPos, Ypos + 1)
            color9 = image.GetPixel(xPos + 1, Ypos + 1)
            color4 = image.GetPixel(xPos - 1, Ypos)
            color6 = image.GetPixel(xPos + 1, Ypos)
            color5 = image.GetPixel(xPos, Ypos)

            If (CType(color5.R, Integer) > CType(color4.R, Integer) - bias) And (CType(color5.R, Integer) < CType(color4.R, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.G, Integer) > CType(color4.G, Integer) - bias) And (CType(color5.G, Integer) < CType(color4.G, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.B, Integer) > CType(color4.B, Integer) - bias) And (CType(color5.B, Integer) < CType(color4.B, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.R, Integer) > CType(color8.R, Integer) - bias) And (CType(color5.R, Integer) < CType(color8.R, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.G, Integer) > CType(color8.G, Integer) - bias) And (CType(color5.G, Integer) < CType(color8.G, Integer) + bias) Then
                change += 1

            End If
            If (CType(color5.B, Integer) > CType(color8.B, Integer) - bias) And (CType(color5.B, Integer) < CType(color8.B, Integer) + bias) Then
                change += 1

            End If
        End If

        'Dim sumR, sumG, sumB As Integer

        'sumR = (CType(color1.R, Integer) + CType(color2.R, Integer) + CType(color3.R, Integer))
        'sumR -= (CType(color7.R, Integer) + CType(color8.R, Integer) + CType(color9.R, Integer))
        ''sumG = (CType(color7.R, Integer) + CType(color8.R, Integer) + CType(color9.R, Integer))
        ''sumG -= (CType(color1.G, Integer) + CType(color2.G, Integer) + CType(color3.G, Integer))
        ''sumB = (CType(color1.B, Integer) + CType(color2.B, Integer) + CType(color3.B, Integer))
        ''sumB -= (CType(color7.B, Integer) + CType(color8.B, Integer) + CType(color9.B, Integer))
        'sumR = Abs(sumR)
        ''sumG = Abs(sumG)
        ''sumB = Abs(sumB)
        ''Dim sumR2, sumG2, sumB2 As Integer
        ''sumR2 = (CType(color1.R, Integer) + CType(color4.R, Integer) + CType(color7.R, Integer))
        ''sumG2 = (CType(color1.G, Integer) + CType(color4.G, Integer) + CType(color7.G, Integer))
        ''sumB2 = (CType(color1.B, Integer) + CType(color4.B, Integer) + CType(color7.B, Integer))
        ''sumR2 -= (CType(color3.R, Integer) + CType(color6.R, Integer) + CType(color9.R, Integer))
        ''sumG2 -= (CType(color3.G, Integer) + CType(color6.G, Integer) + CType(color9.G, Integer))
        ''sumB2 -= (CType(color3.B, Integer) + CType(color6.B, Integer) + CType(color9.B, Integer))
        ''sumR2 = Abs(sumR2)
        ''sumG2 = Abs(sumG2)
        ''sumB2 = Abs(sumB2)

        ''sumR2 = color1.R + color4.R + color7.R
        ''sumG2 = color1.G + color4.G + color7.G
        ''sumB2 = color1.B + color4.B + color7.B
        ''sumR2 -= color3.R + color6.R + color9.R
        ''sumG2 -= color3.G + color6.G + color9.G
        ''sumB2 -= color3.B + color6.B + color9.B
        If change = 6 Then
            result = True
        End If
        Return result
    End Function
    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
            For j As Integer = 0 To marker
                Try
                    bmp1.SetPixel(x + j, y + i, Color.Green)
                Catch ex As Exception

                End Try
            Next
        Next
        Return bmp1

    End Function
    Public Function contourImage(ByVal bmp As Bitmap) As Bitmap

        For index = 0 To bmp.Height - 1
            For j = 0 To bmp.Width - 1
                checkedMatrix(j, index) = False
                imageMatrix(j, index) = is_pixel_dark_at(j, index, bmp, 30)
                'If imageMatrix(j, index) Then
                '    MsgBox(j, index)
                'End If
            Next

        Next
        minX = bmp.Width
        minY = bmp.Height
        maxX = 0
        maxY = 0
        Dim jindex As Integer = 0
        Icounter = 0
        For i = 0 To bmp.Height - 1 Step 5

            While jindex < bmp.Width - 1
                If Not checkedMatrix(jindex, i) Then
                    If Not imageMatrix(jindex, i) Then
                        checkedMatrix(jindex, i) = True
                    Else
                        tracer(bmp, bmp.Width, bmp.Height, jindex, i)
                        HX(Icounter) = maxX
                        LX(Icounter) = minX
                        HY(Icounter) = maxY
                        LY(Icounter) = minY
                        Icounter += 1
                        minX = bmp.Width
                        minY = bmp.Height
                        maxX = 0
                        maxY = 0
                        jindex = jumpImage(jindex, i)
                    End If
                End If



                jindex += 5
            End While
            jindex = 0
        Next

        For index = 0 To Icounter
            bmp = graphicContour(bmp, LX(index), HX(index), LY(index), HY(index))
        Next

        Return bmp

    End Function
    Public Function jumpImage(ByVal x, y) As Integer
        If Icounter > 999 Then
            Icounter = 999
        End If
        Dim n As Integer = 0
        For index = 0 To Icounter
            If (LX(index) <= x And HX(index) >= x) And (LY(index) <= y And HY(index) >= y) Then
                n = HX(index)
            End If
        Next
        Return n
    End Function
    Public Shared Function graphicContour(ByVal bmp As Bitmap, ByVal xmin As Integer, ByVal xmax As Integer, ByVal ymin As Integer, ByVal ymax As Integer) As Bitmap
        For i = xmin To xmax
            bmp = mark_dark_pixel(i, ymin, bmp, 1)
            bmp = mark_dark_pixel(i, ymax, bmp, 1)
        Next
        For i = ymin To ymax
            bmp = mark_dark_pixel(xmin, i, bmp, 1)
            bmp = mark_dark_pixel(xmax, i, bmp, 1)
        Next
        Return bmp
    End Function
    Private Sub tracer(ByVal bmp1 As Bitmap, ByVal w1 As Integer, ByVal h1 As Integer, ByVal x As Integer, ByVal y As Integer)
        If (x > 0 And x < w1) And (y > 0 And y < h1) Then
            If Not checkedMatrix(x, y) Then
                checkedMatrix(x, y) = True
                If imageMatrix(x, y) Then 'not black pixel
                    maxer(x, maxX)
                    maxer(y, maxY)
                    miner(x, minX)
                    miner(y, minY)
                    tracer(bmp1, w1, h1, x - 5, y - 5)
                    tracer(bmp1, w1, h1, x, y - 5)
                    tracer(bmp1, w1, h1, x + 5, y - 5)
                    tracer(bmp1, w1, h1, x - 5, y)
                    tracer(bmp1, w1, h1, x + 5, y)
                    tracer(bmp1, w1, h1, x - 5, y + 5)
                    tracer(bmp1, w1, h1, x, y + 5)
                    tracer(bmp1, w1, h1, x + 5, y + 5)
                End If
            End If
        End If
    End Sub
    Public Sub maxer(ByVal a As Integer, ByRef b As Integer)
        If a > b Then
            b = a
        End If
    End Sub
    Public Sub miner(ByVal a As Integer, ByRef b As Integer)
        If a < b Then
            b = a
        End If
    End Sub

End Class
Public Class ImageList
    Public minX As Integer
    Public minY As Integer
    Public maxX As Integer
    Public maxY As Integer
End Class
Title: Re: outline from gadient mask
Post by: keghn on April 01, 2017, 08:05:29 pm
 I thought it is working the way you wanted?
 I only work in C/C++ and bash.
Title: Re: outline from gadient mask
Post by: yotamarker on April 01, 2017, 08:27:25 pm
the traces errors for complex images.
stack overflow, app gets stuck, out of range exceptions, just a leaf in the image
is enough to give it a seizure.
Title: Re: outline from gadient mask
Post by: yotamarker on April 01, 2017, 09:27:10 pm
https://youtu.be/ynZY961YYMg
Title: Re: outline from gadient mask
Post by: korrelan on April 02, 2017, 10:35:08 am
It’s really hard too see what’s happening in the vid lol.

As I explained earlier one of the main problems you’re going to encounter is JPG compression artifacts.  Try to use BMP or TIF images for your trace experiments.

https://en.wikipedia.org/wiki/Compression_artifact

If the program is working on simple images then it’s probably a complexity explosion problem.

Also change the program so you can see just the outline in the right picture box.  Then superimpose your boundaries on it so you can better see the problems.  Adapt the visual output of the code so you can visually debug it.

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 02, 2017, 03:50:16 pm
phase 1 getting the horizontal bounds.
the problem is with the picture with that little Russian girl with leafs behind her and the ryu pic
Title: Re: outline from gadient mask
Post by: korrelan on April 02, 2017, 05:50:36 pm
OK I've been out for a steak and a few pints... And I really don't mean to sound sarcastic but... Could it be the outlines of the four million, billion, trillion leaves that's overwhelming your array bounds?

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 02, 2017, 06:28:02 pm
yes, originally I thought separating the objects by "not out line pixel line"
would work for all cases. I think to solve this I'll have to consider also
lines with consecutive clusters of none outline as "not out line pixel line" may solve it.

what do you think ?

also I never drank alcohol what does it feel like ?
Title: Re: outline from gadient mask
Post by: yotamarker on April 03, 2017, 04:42:05 pm
it pretty much works now, I"ll need also to address the special cases
I need to make 3 videos :
1 sweet it is solved video
3 explaining the algorithm
2 ranting about the hell I went through
Title: Re: outline from gadient mask
Post by: yotamarker on April 04, 2017, 08:28:10 pm
https://www.youtube.com/watch?v=7wGYwg7dTJI (https://www.youtube.com/watch?v=7wGYwg7dTJI)

(https://i.imgflip.com/1mofgj.jpg) (https://imgflip.com/i/1mofgj) (https://imgflip.com/memegenerator)
Title: Re: outline from gadient mask
Post by: yotamarker on April 06, 2017, 06:25:22 pm
now it is needed to get each of the overlapping image in the rectangle separately
in the example below it needs a rectangle for the chair and a rectangle for the guy.

(https://i.imgflip.com/1msskq.jpg) (https://imgflip.com/i/1msskq) (https://imgflip.com/memegenerator)

any algorithm suggestions ?
Title: Re: outline from gadient mask
Post by: keghn on April 07, 2017, 12:13:15 am
 A trained Neural Network can do that. Or a video tracking algorithm that tracks the person getting in and out of the wheel chair.
 It would pull information from other frames.
 Tracks two objects to their collision or merging.
Title: Re: outline from gadient mask
Post by: yotamarker on April 07, 2017, 01:32:05 am
he isn't getting out of the chair because it is a sign.
Title: Re: outline from gadient mask
Post by: Freddy on April 07, 2017, 01:41:49 am
Hilarious  ;D
Title: Re: outline from gadient mask
Post by: keghn on April 07, 2017, 03:06:51 pm
  My statement sill stands. The human in the sigh could be a cartoon video character. Still, A CNN could detect human real or
in a sign or in a cartoon video in a static image. They are that good. And they are pretrained on may examples before they work.

 A hand crafted program could do it but would only work with that program and that sign only. It would not be machine learning.
Title: Re: outline from gadient mask
Post by: yotamarker on April 07, 2017, 04:46:03 pm
@batman I haven't a clue what your talking about show me the step by step algorithm.
Title: Re: outline from gadient mask
Post by: keghn on April 07, 2017, 04:57:19 pm
Here it is. But it is in C programing language:

https://pjreddie.com/darknet/imagenet/

https://pjreddie.com/darknet/yolo/

https://pjreddie.com/darknet/
Title: Re: outline from gadient mask
Post by: yotamarker on April 07, 2017, 06:24:00 pm
there is no algorithm there it is simply a brag link, "hey look at our cool software".
Title: Re: outline from gadient mask
Post by: korrelan on April 08, 2017, 02:33:11 pm
I’m pleased you got the basic outline routine working.

I presume your idea is that once you have the bounding limits of your object you are going to search against a dataset to find the object?  As I stated earlier in the thread you are going to hit limitations to this technique at every stage. 

Consider shadows for example.  Shadows obviously exist in any ‘real world’ scene. They are going to give you false outlines and throw your recognition routines off (middle image).  Also using black and white images or objects on a white/ mono colour background is giving you a false sense of accuracy for your routines.

(http://i.imgur.com/o8Sp4WQ.jpg)

But if you are still intent on following this technique then I will suggest a few other methods/ thoughts along similar lines that might help you; but we are now crossing the line into convolution territory.

The first thing I would do is to segment the image/ lower the images resolution by reading the RGB stepped x,y points into an array.  This will both speed up processing and allow any derived templates to be scaled at a later date to help negate scale invariance.

As show in the above image (on right) using a similar routine to the colour contrast outline I suggested you can posterize the colour palette of the image points in the array. 

.red_bias=60
.red=red*red_bias
.if red>255 then red=255
.do above for RGB

This will have the effect of highlighting the blocks of similar colours. You can adjust the individual colour biases depending on the image you are processing.

(http://i.imgur.com/ZvwlyNU.jpg)

Section A in image.

Once you have the low resolution image posterized you could check each x,y array location against a object stack. 

Check the RGB of each block in turn against an array list of RGB values already read from the image.  If the RGB of the block being checked is similar (using another bias) to the block on its left then give it the same number value.  If there is a large difference search your list of already known colours and if found get the number from there or if not found add it to the list and start a number.  You could build a dataset of know hues for faces etc.

You should end up with an array of x,y points where each colour block/ object part has a different number.  You can then easily take your boundaries from this or combine/ average the results with the outline routine boundaries.

Section B in image.

Another method to find the outline of objects could be to use a simple trig routine that checks for a line/ colour change in a clockwise direction at a set diameter from a known point.  If used correctly with convolution filters this would trace the perimeter of a objects colour/ line boundaries.  As the point you are checking is rotated and hits a similar value use that as the centre for the next rotation/ search.  When the start vector is close in proximity to the end vector the loop/ boundary can be closed and logged.  Branches of lines, colour changes will need to be tracked and followed individually of course.

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 08, 2017, 03:38:36 pm
you put water in to a cup, it becomes the cup
you put water in to a Tcup, it becomes the Tcup

the key to the recognition would be:
1 linking chronological variations of the image as long as the image is in the frame.
2 giving more importance to the attributes of the image that manifest the A.Is goals :
markers, colors, corners, size.

first though I need to separate the guy in the sign from his wheel chair.

I encountered another time consuming problem : visual studio xamarin compiler doesn't work, the hello
world apk I made doesn't appear on the emulator, so I learned c# for nothing, and I need to learn android studio
so that the A.I would use a phone which weights less than a laptop.
Title: Re: outline from gadient mask
Post by: Freddy on April 08, 2017, 05:04:58 pm
Quote
you put water in to a cup, it becomes the cup
you put water in to a Tcup, it becomes the Tcup

I don't think so. Otherwise how are you going to differentiate between a cup of tea and a cup of coffee.
Title: Re: outline from gadient mask
Post by: yotamarker on April 08, 2017, 06:15:23 pm
I meant the shape of
Title: Re: outline from gadient mask
Post by: keghn on April 09, 2017, 10:24:10 pm
i see three objects. The head. the body. the large letter "C"

All three can be turned to chain code.

 Relative chain code are the list of angle values to the next dot. like 10 degrees, 11 degrees, -5 degrees, 12, -5 and so on.

 The starting point would be at the highest point and go around counter clock wise.

 Rule one. The sum of relative chain code for a complete circle is |360| degrees. that would be the head.

 Rule two. The sum of relative angled chain code around a rough blob is also |360| degrees. Surprise? So that would be
the wheel that looks like a "C" and the body.

The head would be 120 dots at all 3 degrees to the next one inline.
So now instead of having a image you can convert the image into a data base. so if you loose the image it can be recreated from the data base.
The head's chain code would look like in the data base would be 120, 3, 500,50.
The 500, 50 is absolute starting position of the head. 500 pixel the right and 50 pixel down.

With objects entered into a data base in this format mean they can be hit with a million types of algorithms. And thus gives you access to what you seek. Morphing images?


Title: Re: outline from gadient mask
Post by: yotamarker on April 10, 2017, 02:13:17 pm
the head breaks of anyways
the body has a break off from the chair that should be utilized
Title: Re: outline from gadient mask
Post by: keghn on April 10, 2017, 04:29:49 pm
 The following are guess of the features of the body in relative chain code of a descriptor list.
relative chain code  Features of body outline
pixel length, angles
30,3               +90   back of shoulders
90,0               0     back
30,3               90   joint
100,0               0   back thigh
1,-45               -45   back of knee
90,0               0   back leg
1,90               90   heel
30,0               0   bottom foot
30,6               180 toes
30,0               0    top of foot
1,-90               -90 joint
89,0               0   front of leg shin
15,3               +45   knee
89,0               0   thigh
1,-90               -90 joint
15,0               0   
1,-90               -90  joint
77,0               0   bottom of arm/handle of wheel chair
20,9               +180 fist/hand
77,0               0 top of arm
1,-90               -90
60,0               0 chest
30,3               +90 shoulders, front

909            outline is 909 pixels long.
500, 100 absolute starting position for the body.

If you want to move the body away from the chair or the head then just add  the same movement
value to the absolute x or y position of each body pixel of the body outline.

 If you want to double the size, then multiply all of the pixel lengths by 2,
 To make it half the size divide by two.

 if you want the  arms to move then change the angles at the joints:-)

 But will need to code a subroutine to deal with chain code.
Title: Re: outline from gadient mask
Post by: yotamarker on April 12, 2017, 03:45:30 pm
I'm getting some psyco overlapping rectangles


(https://i.imgflip.com/1n4jfm.jpg) (https://imgflip.com/i/1n4jfm) (https://imgflip.com/memegenerator)

@kei10 any thoughts ?
Title: Re: outline from gadient mask
Post by: yotamarker on April 12, 2017, 03:48:40 pm
(https://i.imgflip.com/1n4jql.jpg) (https://imgflip.com/i/1n4jql) (https://imgflip.com/memegenerator)
Title: Re: outline from gadient mask
Post by: yotamarker on April 12, 2017, 03:50:21 pm
maybe it's not going through the whole thing
Title: Re: outline from gadient mask
Post by: yotamarker on April 12, 2017, 04:03:30 pm
maybe I could tweak it
and then I shall eat bananas and none shell stop me bwa ha ha

https://www.youtube.com/watch?v=X-Y6YfDBmh8 (https://www.youtube.com/watch?v=X-Y6YfDBmh8)
Title: Re: outline from gadient mask
Post by: keghn on April 12, 2017, 06:45:53 pm
 I personally find this very interesting and is important work.

 I see a seven sided Heptagon:

https://en.wikipedia.org/wiki/Heptagon


 One "outline" classification is one outline that do not have lines inside. So there are seven triangles. A seven separate descriptions are needed. That is if you are interested in enter them into a descriptor data base, later on?

 So when searching lines you will come to decision branch of with line to scan out. Like a fork in the road.

 There is a eighth outline is the outline of heptagon with with no spokes within,. And there are even more. like a pie with bite
taken out. That is the heptagon with one sub triangle taken out. or more: 

https://en.wikipedia.org/wiki/Low_poly
Title: Re: outline from gadient mask
Post by: yotamarker on April 12, 2017, 08:07:51 pm
Russian leaf girl gonna be a tough boss.
Title: Re: outline from gadient mask
Post by: keghn on April 12, 2017, 09:37:56 pm
 I know Just brought to think about in the back of your head when you have the time.
Title: Re: outline from gadient mask
Post by: yotamarker on April 13, 2017, 08:59:25 pm
https://www.youtube.com/watch?v=nKDnOfaAGu0 (https://www.youtube.com/watch?v=nKDnOfaAGu0)
Title: Re: outline from gadient mask
Post by: yotamarker on April 17, 2017, 10:38:28 am
https://www.youtube.com/watch?v=Oqqyc1-90NI (https://www.youtube.com/watch?v=Oqqyc1-90NI)

the alg is too massive.
Title: Re: outline from gadient mask
Post by: yotamarker on April 17, 2017, 10:51:41 am
please post an alg for recognizing colors
Title: Re: outline from gadient mask
Post by: yotamarker on April 17, 2017, 12:00:57 pm
https://www.youtube.com/watch?v=I0Sg7nD8kD8 (https://www.youtube.com/watch?v=I0Sg7nD8kD8)
Title: Re: outline from gadient mask
Post by: keghn on April 17, 2017, 02:46:41 pm
 Very interesting. You are making great progress! Wow, you are picking up a lot of detail with the edge detector, may be a little
too much. May need to blur the image so computer cannot see each hair fiber? I know you know. I just like talking out loud.

Title: Re: outline from gadient mask
Post by: yotamarker on April 17, 2017, 04:34:25 pm
thanks man.
at any rate : as for the leafs I was thinking about using motion detection to see where the girl is.

also the alg I used for recognizing the C of the wheelchair sign is also too slow.

I am interested in:
1 any additional solution for the leafs
2 a blur alg
3 and in a get pixel color alg. something more accurate than what I wrote back in the day :
Code: [Select]
Public Class Form1 ' code amped by .paul
    Dim curPixelX As Integer = 0
    Dim curPixelY As Integer = 0
    Dim r1, g1, b1 As Integer
    Dim curColorChar As Char = Nothing
    Dim bm As Bitmap
    Sub RGB_breakerBuster(ByVal inColor As Color, ByRef red As Integer, ByRef green As Integer, ByRef blue As Integer)
        ' returns value of red,green,blue in a pixel of a bitmap as integers
        red = inColor.R
        green = inColor.G
        blue = inColor.B
    End Sub
    Public Function getPixelColor(ByVal r As Integer, ByVal g As Integer, ByVal b As Integer) As Char
        ' r= red, g = green, b = blue
        Dim colorchar As Char
        If r > 245 And g > 245 And b > 245 Then
            colorchar = "w" ' white
        ElseIf r < 20 And g < 20 And b < 20 Then
            colorchar = "k" ' black (kuro in japanese)
        ElseIf r > g And g > b And g < 100 Then
            colorchar = "r" ' red
        ElseIf r > g And g > b And g > 200 Then
            colorchar = "y" ' yellow
        ElseIf r > g And g > b And 100 < g < 200 Then
            colorchar = "o" 'orange
        ElseIf (g > r And r > b) Or (g > b And b > r) Then
            colorchar = "g" 'green
        ElseIf b > g And g > r Then
            colorchar = "b" 'blue
        ElseIf (b > r And r > g) Or (r > b And g < 20) Then
            colorchar = "v" ' violet
        Else
            colorchar = "u" ' yet undefined
        End If
        Return colorchar
    End Function
    Sub colorLegend()
        ' converts color char to the color name
        ' label2 = getPixelColor(r1, g1, b1) 1st colorchar
        ' label3 = color represented by colorchar
        Select Case Label2.Text
            Case "w"
                Label3.Text = "white"

            Case "k"

                Label3.Text = "black"
            Case "r"
                Label3.Text = "red"
            Case "y"
                Label3.Text = "yellow"
            Case "o"
                Label3.Text = "orange"
            Case "g"
                Label3.Text = "green"
            Case "b"
                Label3.Text = "blue"
            Case "v"
                Label3.Text = "violate"
            Case Else

        End Select

    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Try
            TextBox1.Text = bm.GetPixel(curPixelX, curPixelY).ToString()
            RGB_breakerBuster(bm.GetPixel(curPixelX, curPixelY), r1, g1, b1)
            TextBox2.Text = r1 & " " & g1 & " " & b1
            bm.SetPixel(curPixelX, curPixelY, Color.Black)
            PictureBox1.Image = bm
            curPixelX += 1
            Label2.Text = getPixelColor(r1, g1, b1)
            colorLegend()
        Catch ex As Exception
            Timer1.Enabled = False
            MsgBox("done")
        End Try

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Enabled = Not Timer1.Enabled
        bm = PictureBox1.Image
        curPixelY = bm.Height \ 2
    End Sub
End Class
Title: Re: outline from gadient mask
Post by: korrelan on April 17, 2017, 05:28:01 pm
Better colour naming

Strip the colour names and RGB values from the page and write a simple closest match routine.

http://cloford.com/resources/colours/500col.htm (http://cloford.com/resources/colours/500col.htm)

Simple blurring

sample the pixels on the leading side the pixel you are scanning and average the results. So if you scanning left to right/ top to bottom; sample the pixels at x,y .. x+1,y .. x+1,y+1 .. x,y+1.. divide by 4 and set the RGB of x,y to the new value.

Extracting the girl/ objects from the leafs

Build a skin tone colour pallet.  You should then be able to highlight any skin tones in a picture; or indeed a leaf extraction pallet.

I suppose the ideal method is to run the picture through several convolution filters; each designed to extract/ highlight different aspects.  Then average all the results to get the final boundaries.

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 17, 2017, 06:23:56 pm
the problem with your solution is that it is specific for that image but what if it's a dog in front of yellow autom leafs
or a tanned girl in front of pink leafs
Title: Re: outline from gadient mask
Post by: yotamarker on April 17, 2017, 06:26:33 pm
also I think about tracing the outline pixels would not work if the outline is not consistant
like the case of mouths.
Title: Re: outline from gadient mask
Post by: yotamarker on April 17, 2017, 06:38:10 pm
apart from motion detection other solutions maybe :

a color tracer that ignores the main appearing color, and *ignores black
also the tracing can not be of too many colors as this would not hold a substantial shape.
another problem with this is that the alg runs at least twice :
once to get the colors, once to process. a possible solution to this is to process a smaller portion of the image.

what do you think ?
Title: Re: outline from gadient mask
Post by: yotamarker on April 17, 2017, 08:56:00 pm
cluster color ! 1.21 gigawatts !
Title: Re: outline from gadient mask
Post by: korrelan on April 17, 2017, 09:44:04 pm
Quote
the problem with your solution is that it is specific for that image but what if it's a dog in front of yellow autom leafs or a tanned girl in front of pink leafs

I know you are hoping to find one algorithm/ technique to handle all images but I think that’s going to be impossible.  Your system is going to have to adapt and use different filters/ pallets to extract information from an image.

Motion detection would probably help over several frames and background occlusion would also give a hint at the objects outline.

Quote
a possible solution to this is to process a smaller portion of the image.

Yes… you could process the image in blocks, or sub-sample the image down to a lower resolution to speed things up.  Perhaps reading the pixel information into an array just once and then performing operations on that might be faster; you could read every third pixel for example and achieve both at the same time.

For objects on a plain/ monochrome background this outline/ boundary technique will work up to a point.  Your main problem is that to define a boundary the system has to have an idea of the shape of the objects it’s looking for; it’s a top down/ bottom up process.  A object recognition system like has to learn to recognise objects as it learns to see the objects.

Using stereo depth perception from either two cameras, a prism/ mirror rig on one camera or a Kinect makes it much easier to define the outline of an object in a scene using the displacement map. The stereo displacement is directly proportional to the distance from the camera.  If this project is for a bot then you might as well start with a stereo system.

https://inst.eecs.berkeley.edu/~cs61c/fa14/projs/01/

You really need to consider ‘feature detection’ as an alternative method… but it seems like your enjoying your project and learning a lot as you go… which is all good.


Code: [Select]
indian red,176,23,31
crimson,220,20,60
lightpink,255,182,193
lightpink 1,255,174,185
lightpink 2,238,162,173
lightpink 3,205,140,149
lightpink 4,139,95,101
pink,255,192,203
pink 1,255,181,197
pink 2,238,169,184
pink 3,205,145,158
pink 4,139,99,108
palevioletred,219,112,147
palevioletred 1,255,130,171
palevioletred 2,238,121,159
palevioletred 3,205,104,137
palevioletred 4,139,71,93
lavenderblush 1,255,240,245
lavenderblush 2,238,224,229
lavenderblush 3,205,193,197
lavenderblush 4,139,131,134
violetred 1,255,62,150
violetred 2,238,58,140
violetred 3,205,50,120
violetred 4,139,34,82
hotpink,255,105,180
hotpink 1,255,110,180
hotpink 2,238,106,167
hotpink 3,205,96,144
hotpink 4,139,58,98
raspberry,135,38,87
deeppink 1,255,20,147
deeppink 2,238,18,137
deeppink 3,205,16,118
deeppink 4,139,10,80
maroon 1,255,52,179
maroon 2,238,48,167
maroon 3,205,41,144
maroon 4,139,28,98
mediumvioletred,199,21,133
violetred,208,32,144
orchid,218,112,214
orchid 1,255,131,250
orchid 2,238,122,233
orchid 3,205,105,201
orchid 4,139,71,137
thistle,216,191,216
thistle 1,255,225,255
thistle 2,238,210,238
thistle 3,205,181,205
thistle 4,139,123,139
plum 1,255,187,255
plum 2,238,174,238
plum 3,205,150,205
plum 4,139,102,139
plum,221,160,221
violet,238,130,238
magenta (fuchsia*),255,0,255
magenta 2,238,0,238
magenta 3,205,0,205
magenta 4,139,0,139
purple*,128,0,128
mediumorchid,186,85,211
mediumorchid 1,224,102,255
mediumorchid 2,209,95,238
mediumorchid 3,180,82,205
mediumorchid 4,122,55,139
darkviolet,148,0,211
darkorchid,153,50,204
darkorchid 1,191,62,255
darkorchid 2,178,58,238
darkorchid 3,154,50,205
darkorchid 4,104,34,139
indigo,75,0,130
blueviolet,138,43,226
purple 1,155,48,255
purple 2,145,44,238
purple 3,125,38,205
purple 4,85,26,139
mediumpurple,147,112,219
mediumpurple 1,171,130,255
mediumpurple 2,159,121,238
mediumpurple 3,137,104,205
mediumpurple 4,93,71,139
darkslateblue,72,61,139
lightslateblue,132,112,255
mediumslateblue,123,104,238
slateblue,106,90,205
slateblue 1,131,111,255
slateblue 2,122,103,238
slateblue 3,105,89,205
slateblue 4,71,60,139
ghostwhite,248,248,255
lavender,230,230,250
blue*,0,0,255
blue 2,0,0,238
blue 3 (mediumblue),0,0,205
blue 4 (darkblue),0,0,139
navy*,0,0,128
midnightblue,25,25,112
cobalt,61,89,171
royalblue,65,105,225
royalblue 1,72,118,255
royalblue 2,67,110,238
royalblue 3,58,95,205
royalblue 4,39,64,139
cornflowerblue,100,149,237
lightsteelblue,176,196,222
lightsteelblue 1,202,225,255
lightsteelblue 2,188,210,238
lightsteelblue 3,162,181,205
lightsteelblue 4,110,123,139
lightslategray,119,136,153
slategray,112,128,144
slategray 1,198,226,255
slategray 2,185,211,238
slategray 3,159,182,205
slategray 4,108,123,139
dodgerblue 1,30,144,255
dodgerblue 2,28,134,238
dodgerblue 3,24,116,205
dodgerblue 4,16,78,139
aliceblue,240,248,255
steelblue,70,130,180
steelblue 1,99,184,255
steelblue 2,92,172,238
steelblue 3,79,148,205
steelblue 4,54,100,139
lightskyblue,135,206,250
lightskyblue 1,176,226,255
lightskyblue 2,164,211,238
lightskyblue 3,141,182,205
lightskyblue 4,96,123,139
skyblue 1,135,206,255
skyblue 2,126,192,238
skyblue 3,108,166,205
skyblue 4,74,112,139
skyblue,135,206,235
deepskyblue 1,0,191,255
deepskyblue 2,0,178,238
deepskyblue 3,0,154,205
deepskyblue 4,0,104,139
peacock,51,161,201
lightblue,173,216,230
lightblue 1,191,239,255
lightblue 2,178,223,238
lightblue 3,154,192,205
lightblue 4,104,131,139
powderblue,176,224,230
cadetblue 1,152,245,255
cadetblue 2,142,229,238
cadetblue 3,122,197,205
cadetblue 4,83,134,139
turquoise 1,0,245,255
turquoise 2,0,229,238
turquoise 3,0,197,205
turquoise 4,0,134,139
cadetblue,95,158,160
darkturquoise,0,206,209
azure 1 (azure),240,255,255
azure 2,224,238,238
azure 3,193,205,205
azure 4,131,139,139
lightcyan 1,224,255,255
lightcyan 2,209,238,238
lightcyan 3,180,205,205
lightcyan 4,122,139,139
paleturquoise 1,187,255,255
paleturquoise 2,174,238,238
paleturquoise 3,150,205,205
paleturquoise 4,102,139,139
darkslategray,47,79,79
darkslategray 1,151,255,255
darkslategray 2,141,238,238
darkslategray 3,121,205,205
darkslategray 4,82,139,139
cyan / aqua*,0,255,255
cyan 2,0,238,238
cyan 3,0,205,205
cyan 4 (darkcyan),0,139,139
teal*,0,128,128
mediumturquoise,72,209,204
lightseagreen,32,178,170
manganeseblue,3,168,158
turquoise,64,224,208
coldgrey,128,138,135
turquoiseblue,0,199,140
aquamarine 1,127,255,212
aquamarine 2,118,238,198
aquamarine 3,102,205,170
aquamarine 4,69,139,116
mediumspringgreen,0,250,154
mintcream,245,255,250
springgreen,0,255,127
springgreen 1,0,238,118
springgreen 2,0,205,102
springgreen 3,0,139,69
mediumseagreen,60,179,113
seagreen 1,84,255,159
seagreen 2,78,238,148
seagreen 3,67,205,128
seagreen 4,46,139,87
emeraldgreen,0,201,87
mint,189,252,201
cobaltgreen,61,145,64
honeydew 1,240,255,240
honeydew 2,224,238,224
honeydew 3,193,205,193
honeydew 4,131,139,131
darkseagreen,143,188,143
darkseagreen 1,193,255,193
darkseagreen 2,180,238,180
darkseagreen 3,155,205,155
darkseagreen 4,105,139,105
palegreen,152,251,152
palegreen 1,154,255,154
palegreen 2,144,238,144
palegreen 3,124,205,124
palegreen 4,84,139,84
limegreen,50,205,50
forestgreen,34,139,34
green 1 (lime*),0,255,0
green 2,0,238,0
green 3,0,205,0
green 4,0,139,0
green*,0,128,0
darkgreen,0,100,0
sapgreen,48,128,20
lawngreen,124,252,0
chartreuse 1,127,255,0
chartreuse 2,118,238,0
chartreuse 3,102,205,0
chartreuse 4,69,139,0
greenyellow,173,255,47
darkolivegreen 1,202,255,112
darkolivegreen 2,188,238,104
darkolivegreen 3,162,205,90
darkolivegreen 4,110,139,61
darkolivegreen,85,107,47
olivedrab,107,142,35
olivedrab 1,192,255,62
olivedrab 2,179,238,58
olivedrab 3,154,205,50
olivedrab 4,105,139,34
ivory 1 (ivory),255,255,240
ivory 2,238,238,224
ivory 3,205,205,193
ivory 4,139,139,131
beige,245,245,220
lightyellow 1,255,255,224
lightyellow 2,238,238,209
lightyellow 3,205,205,180
lightyellow 4,139,139,122
lightgoldenrodyellow,250,250,210
yellow 1 (yellow*),255,255,0
yellow 2,238,238,0
yellow 3,205,205,0
yellow 4,139,139,0
warmgrey,128,128,105
olive*,128,128,0
darkkhaki,189,183,107
khaki 1,255,246,143
khaki 2,238,230,133
khaki 3,205,198,115
khaki 4,139,134,78
khaki,240,230,140
palegoldenrod,238,232,170
lemonchiffon 1,255,250,205
lemonchiffon 2,238,233,191
lemonchiffon 3,205,201,165
lemonchiffon 4,139,137,112
lightgoldenrod 1,255,236,139
lightgoldenrod 2,238,220,130
lightgoldenrod 3,205,190,112
lightgoldenrod 4,139,129,76
banana,227,207,87
gold 1 (gold),255,215,0
gold 2,238,201,0
gold 3,205,173,0
gold 4,139,117,0
cornsilk 1 (cornsilk),255,248,220
cornsilk 2,238,232,205
cornsilk 3,205,200,177
cornsilk 4,139,136,120
goldenrod,218,165,32
goldenrod 1,255,193,37
goldenrod 2,238,180,34
goldenrod 3,205,155,29
goldenrod 4,139,105,20
darkgoldenrod,184,134,11
darkgoldenrod 1,255,185,15
darkgoldenrod 2,238,173,14
darkgoldenrod 3,205,149,12
darkgoldenrod 4,139,101,8
orange 1 (orange),255,165,0
orange 2,238,154,0
orange 3,205,133,0
orange 4,139,90,0
floralwhite,255,250,240
oldlace,253,245,230
wheat,245,222,179
wheat 1,255,231,186
wheat 2,238,216,174
wheat 3,205,186,150
wheat 4,139,126,102
moccasin,255,228,181
papayawhip,255,239,213
blanchedalmond,255,235,205
navajowhite 1,255,222,173
navajowhite 2,238,207,161
navajowhite 3,205,179,139
navajowhite 4,139,121,94
eggshell,252,230,201
tan,210,180,140
brick,156,102,31
cadmiumyellow,255,153,18
antiquewhite,250,235,215
antiquewhite 1,255,239,219
antiquewhite 2,238,223,204
antiquewhite 3,205,192,176
antiquewhite 4,139,131,120
burlywood,222,184,135
burlywood 1,255,211,155
burlywood 2,238,197,145
burlywood 3,205,170,125
burlywood 4,139,115,85
bisque 1 (bisque),255,228,196
bisque 2,238,213,183
bisque 3,205,183,158
bisque 4,139,125,107
melon,227,168,105
carrot,237,145,33
darkorange,255,140,0
darkorange 1,255,127,0
darkorange 2,238,118,0
darkorange 3,205,102,0
darkorange 4,139,69,0
orange,255,128,0
tan 1,255,165,79
tan 2,238,154,73
tan 3 (peru),205,133,63
tan 4,139,90,43
linen,250,240,230
peachpuff 1,255,218,185
peachpuff 2,238,203,173
peachpuff 3,205,175,149
peachpuff 4,139,119,101
seashell 1 (seashell),255,245,238
seashell 2,238,229,222
seashell 3,205,197,191
seashell 4,139,134,130
sandybrown,244,164,96
rawsienna,199,97,20
chocolate,210,105,30
chocolate 1,255,127,36
chocolate 2,238,118,33
chocolate 3,205,102,29
chocolate 4,139,69,19
ivoryblack,41,36,33
flesh,255,125,64
cadmiumorange,255,97,3
burntsienna,138,54,15
sienna,160,82,45
sienna 1,255,130,71
sienna 2,238,121,66
sienna 3,205,104,57
sienna 4,139,71,38
lightsalmon 1,255,160,122
lightsalmon 2,238,149,114
lightsalmon 3,205,129,98
lightsalmon 4,139,87,66
coral,255,127,80
orangered 1,255,69,0
orangered 2,238,64,0
orangered 3,205,55,0
orangered 4,139,37,0
sepia,94,38,18
darksalmon,233,150,122
salmon 1,255,140,105
salmon 2,238,130,98
salmon 3,205,112,84
salmon 4,139,76,57
coral 1,255,114,86
coral 2,238,106,80
coral 3,205,91,69
coral 4,139,62,47
burntumber,138,51,36
tomato 1 (tomato),255,99,71
tomato 2,238,92,66
tomato 3,205,79,57
tomato 4,139,54,38
salmon,250,128,114
mistyrose 1,255,228,225
mistyrose 2,238,213,210
mistyrose 3,205,183,181
mistyrose 4,139,125,123
snow 1 (snow),255,250,250
snow 2,238,233,233
snow 3,205,201,201
snow 4,139,137,137
rosybrown,188,143,143
rosybrown 1,255,193,193
rosybrown 2,238,180,180
rosybrown 3,205,155,155
rosybrown 4,139,105,105
lightcoral,240,128,128
indianred,205,92,92
indianred 1,255,106,106
indianred 2,238,99,99
indianred 4,139,58,58
indianred 3,205,85,85
brown,165,42,42
brown 1,255,64,64
brown 2,238,59,59
brown 3,205,51,51
brown 4,139,35,35
firebrick,178,34,34
firebrick 1,255,48,48
firebrick 2,238,44,44
firebrick 3,205,38,38
firebrick 4,139,26,26
red 1 (red*),255,0,0
red 2,238,0,0
red 3,205,0,0
red 4 (darkred),139,0,0
maroon*,128,0,0
sgi beet,142,56,142
sgi slateblue,113,113,198
sgi lightblue,125,158,192
sgi teal,56,142,142
sgi chartreuse,113,198,113
sgi olivedrab,142,142,56
sgi brightgray,197,193,170
sgi salmon,198,113,113
sgi darkgray,85,85,85
sgi gray 12,30,30,30
sgi gray 16,40,40,40
sgi gray 32,81,81,81
sgi gray 36,91,91,91
sgi gray 52,132,132,132
sgi gray 56,142,142,142
sgi lightgray,170,170,170
sgi gray 72,183,183,183
sgi gray 76,193,193,193
sgi gray 92,234,234,234
sgi gray 96,244,244,244
white*,255,255,255
white smoke,245,245,245
gainsboro,220,220,220
lightgrey,211,211,211
silver*,192,192,192
darkgray,169,169,169
gray*,128,128,128
dimgray (gray 42),105,105,105
black*,0,0,0
gray 99,252,252,252
gray 98,250,250,250
gray 97,247,247,247
white smoke,245,245,245
gray 95,242,242,242
gray 94,240,240,240
gray 93,237,237,237
gray 92,235,235,235
gray 91,232,232,232
gray 90,229,229,229
gray 89,227,227,227
gray 88,224,224,224
gray 87,222,222,222
gray 86,219,219,219
gray 85,217,217,217
gray 84,214,214,214
gray 83,212,212,212
gray 82,209,209,209
gray 81,207,207,207
gray 80,204,204,204
gray 79,201,201,201
gray 78,199,199,199
gray 77,196,196,196
gray 76,194,194,194
gray 75,191,191,191
gray 74,189,189,189
gray 73,186,186,186
gray 72,184,184,184
gray 71,181,181,181
gray 70,179,179,179
gray 69,176,176,176
gray 68,173,173,173
gray 67,171,171,171
gray 66,168,168,168
gray 65,166,166,166
gray 64,163,163,163
gray 63,161,161,161
gray 62,158,158,158
gray 61,156,156,156
gray 60,153,153,153
gray 59,150,150,150
gray 58,148,148,148
gray 57,145,145,145
gray 56,143,143,143
gray 55,140,140,140
gray 54,138,138,138
gray 53,135,135,135
gray 52,133,133,133
gray 51,130,130,130
gray 50,127,127,127
gray 49,125,125,125
gray 48,122,122,122
gray 47,120,120,120
gray 46,117,117,117
gray 45,115,115,115
gray 44,112,112,112
gray 43,110,110,110
gray 42,107,107,107
dimgray (gray 42),105,105,105
gray 40,102,102,102
gray 39,99,99,99
gray 38,97,97,97
gray 37,94,94,94
gray 36,92,92,92
gray 35,89,89,89
gray 34,87,87,87
gray 33,84,84,84
gray 32,82,82,82
gray 31,79,79,79
gray 30,77,77,77
gray 29,74,74,74
gray 28,71,71,71
gray 27,69,69,69
gray 26,66,66,66
gray 25,64,64,64
gray 24,61,61,61
gray 23,59,59,59
gray 22,56,56,56
gray 21,54,54,54
gray 20,51,51,51
gray 19,48,48,48
gray 18,46,46,46
gray 17,43,43,43
gray 16,41,41,41
gray 15,38,38,38
gray 14,36,36,36
gray 13,33,33,33
gray 12,31,31,31
gray 11,28,28,28
gray 10,26,26,26
gray 9,23,23,23
gray 8,20,20,20
gray 7,18,18,18
gray 6,15,15,15
gray 5,13,13,13
gray 4,10,10,10
gray 3,8,8,8
gray 2,5,5,5
gray 1,3,3,3


 :)
Title: Re: outline from gadient mask
Post by: keghn on April 17, 2017, 09:55:44 pm
 For myself, I like to change the image and put it into a descriptor table. Of chain codes colors of outline,  absolute position,
relative position, features in the outline, distances of feature to each other in a outline, and relationship of similarity of between
features in a outline, color inside a outline, complete outline length, and length of feature. Then get rid of picture and bring it into existence when needed.


 Or, if you are interested  in staying with images, all the time during the process, then down sample the
image to a really small size where you can barely tell the difference between
one image from  another other. Then  deal with a reduced amount of information. Then
expand back to full size when you need to focus on a detail that you are interested in.

 The simplest would find the dead center of all outlines and just tack them moving around and expand them when needed.

 Or use many thread programing?
 Or use GPU's?

 In chain code, reducing the information is about taking out the bumps in the outline, also known as features in a
outline. In a way that will morph into completely smooth circle. After a certain amounts of iterations.

 The detached head in the early wheel chair picture is already there. It is a circle right now. But the body will take a few hundred rations with a FFT filter like algorithm to rid it of its features, and also any noise. And thus turn in to a circle that is bigger then the head.
 The distance to the centers of the two circles of the body and the head will still be there, untouched by the algorithm.

 I see now that the head is connected in the  wheelchair picture.


 All of his is something to think about.

Title: Re: outline from gadient mask
Post by: korrelan on April 18, 2017, 02:19:12 pm
https://www.youtube.com/watch?v=92NqMLSaZKI (https://www.youtube.com/watch?v=92NqMLSaZKI)

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 18, 2017, 02:46:43 pm
enjoying this ? no, ideally someone else would solve it and I would DL a book and read about it and
buy the product for a reasonable price.

in my specific case I can't let go of a puzzle.
Title: Re: outline from gadient mask
Post by: keghn on April 19, 2017, 12:57:56 am
 I am enjoying it. Also i very sorry for bruising our brain. No need to rush this. May be you should take it easy for few
days? I do not want your brain become too knotted. That will bad in the long run.
Title: Re: outline from gadient mask
Post by: korrelan on April 19, 2017, 02:21:16 pm
https://www.youtube.com/watch?v=uaKe5jvQ3dk (https://www.youtube.com/watch?v=uaKe5jvQ3dk)

Messing around with different object perimeter techniques. This method would obviously have a problem 'seeing' around corners lol. Going to try a matrix with a perimeter trace next.

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 19, 2017, 05:19:50 pm
how does it work ?
Title: Re: outline from gadient mask
Post by: korrelan on April 19, 2017, 05:37:19 pm
Similar in principal to a radar.

Points are defined along a line moving from the centre to the radius of the circle; the line of points is rotated counter clockwise until the complete circumference is covered.  If a major colour change is detected between the centre and the point being checked along the line then it's noted.  So each line of points moving from the centre to the radius will have a point where it crosses into a completely new colour (within a bias range). These points are then joined with a banded/ poly line that joins all the points around the colour boundary together.

 :)
Title: Re: outline from gadient mask
Post by: korrelan on April 20, 2017, 11:40:20 am
I tried several methods of tracing an outline but they all had their limitations.

I like a distraction and a problem to be solved; it needs to be accurate, fast and efficient…

Time to apply a bit of machine learning… I wrote a simple pixel bot.

First I extract a matrix of pixels around the mouse pointer and load them into an array.  Then I ‘posterise’ the pallet of the selected pixels to limit/ blend the number of colours. Next I mark all pixels with a similar colour (within bias range) to the pixel I clicked with the colour blue to make them obvious to me. So any pixels that are similar to the one I click on are now coloured blue.

The bot has a centre from which the outline is drawn and is surrounded by its eight surrounding pixels which are it’s sensors/ eyes.  Each surrounding pixel has a binary value 1,2,4,8,16,32,64,128 which can be simply added together to give a single number that represents the pixel pattern around the bot.  Each of the 255 sensor combinations is mapped to an array along with the +/- x,y directions it should move when it ‘sees’ that pattern.  I can give the bot the relevant direction by pressing the number pad for the eight directions.  The bots sensors pick up on the colour blue.
 
This vid shows me ‘teaching’ the software to follow a perimeter. The bot is the red dot; at the start the bot is on the right boarder of the square.  This is because it was sensing 255 which means it was totally surrounded by blue.  I pressed ‘right’ so the bot move to the right until it hit the boundary; this is where the vid begins.

I then press ‘down’ and it moves down; it now knows when ever it sees the pattern for a vertical line to its right to move down; the rest of the vid is just me teaching the bot which direction to move depending on what it’s sensing around it.  As you will see it quickly improves as it learns.  Toward the end it has no problem following complex outlines using the information it’s learned.

https://www.youtube.com/watch?v=WH9Bc4aF6Nc (https://www.youtube.com/watch?v=WH9Bc4aF6Nc)

Because the outline is mapped into the array I can easily change the scale, get the boundaries/ vectors and center of the shape.

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 20, 2017, 07:54:38 pm
I gave it some thought, (it's not like I can think about anything other than A.I anyways) and that girl
she could be wearing camouflage so motion detection is the best bet. the colors can help for faster recognition.
by the way, what programming environment are you using ?
Title: Re: outline from gadient mask
Post by: keghn on April 20, 2017, 09:54:09 pm
@korrelan program mostly in BASIC?
I program in C++ or C and BASH. All on a Linux operating system.
I am developing my audio softwar for the rest of this year and will be moving to develop my vision software next.
  Cheers
Title: Re: outline from gadient mask
Post by: korrelan on April 20, 2017, 10:09:38 pm
@Yot & Keghn

Yeah! I tend to prototype in VB6/ API; not to be confused with VB.NET which is much too slow for this kind of work.  I write in C++ and compile as DLL’s when I need the extra speed boost; though VB6 has a native compiler and is just as fast for most purposes.

I can code in several languages but I find VB6/ API is a very quick language to develop with; if I have an idea I can have it coded and working in an hour or so.

Use the right tool for the job… lol.

 :)

Good luck with the audio/ vision software.

:)
Title: Re: outline from gadient mask
Post by: yotamarker on April 21, 2017, 02:00:13 pm
wow those are some mad skills, what do you do if you want to make a mobil app ?
Title: Re: outline from gadient mask
Post by: korrelan on April 23, 2017, 11:01:20 am
I've never had to produce a mobile app; but I would probably use HTML5 or Java.

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 23, 2017, 02:49:43 pm
I accidently found out something amazing.
Title: Re: outline from gadient mask
Post by: yotamarker on April 23, 2017, 02:51:34 pm
this was so insane I am now taking suggestions for the next vid's music
Title: Re: outline from gadient mask
Post by: yotamarker on April 23, 2017, 08:34:14 pm
the survey corp took out the female titan

https://www.youtube.com/watch?v=BgoIJzn8M-Y (https://www.youtube.com/watch?v=BgoIJzn8M-Y)
Title: Re: outline from gadient mask
Post by: korrelan on April 23, 2017, 09:28:04 pm
So you have implemented a pallet extraction/ highlight to pick out the tones in the girls skin/ leaf colours?

http://aidreams.co.uk/forum/index.php?topic=12069.msg46524#msg46524 (http://aidreams.co.uk/forum/index.php?topic=12069.msg46524#msg46524)

Cool.  Though like you said…

Quote
the problem with your solution is that it is specific for that image but what if it's a dog in front of yellow autom leafs or a tanned girl in front of pink leafs

This problem still exists.

Good progress though.

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 25, 2017, 04:59:03 pm
could you explain corner detection algorithm ?
also do you have any point of interest regarding motion detection ? like should I detect the overall movement or all movements or other stuff
Title: Re: outline from gadient mask
Post by: yotamarker on April 25, 2017, 05:00:44 pm
also Shi-Tomasi corner-detector and Lukas-Kanade algorithm  ?
Title: Re: outline from gadient mask
Post by: keghn on April 26, 2017, 01:18:01 am
Shi-Tomasi corner-detector: 
https://en.wikipedia.org/wiki/Corner_detection#The_Shi_and_Tomasi_corner_detection_algorithm (https://en.wikipedia.org/wiki/Corner_detection#The_Shi_and_Tomasi_corner_detection_algorithm)

 If you like it use it. Nothing wrong with it. Corners are sub feather in a image that make up an out line of a object.
 So are straight line the the:

https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm (https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm)

https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm (https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm)

https://en.wikipedia.org/wiki/Line_drawing_algorithm (https://en.wikipedia.org/wiki/Line_drawing_algorithm)

 A out line can have set of sub features that identify it like a finger print.  Like six corners and six straight lines.
 So you can find people and planes in a video at light speed. Like a index at the back of a book.

https://en.wikipedia.org/wiki/Marching_squares (https://en.wikipedia.org/wiki/Marching_squares)

https://en.wikipedia.org/wiki/Contour_line (https://en.wikipedia.org/wiki/Contour_line)

optical flow is high lighting the change between two images: 

https://www.youtube.com/watch?v=JSzUdVBmQP4 (https://www.youtube.com/watch?v=JSzUdVBmQP4) 

https://www.youtube.com/watch?v=LjjJQ81RbX0 (https://www.youtube.com/watch?v=LjjJQ81RbX0)

 


Title: Re: outline from gadient mask
Post by: yotamarker on April 26, 2017, 03:21:05 am
that's the problem I don't understand it the way wiki explains it
Title: Re: outline from gadient mask
Post by: yotamarker on April 26, 2017, 05:02:22 am
I hate opencv so much I can't use it on vb.net and it just appears in too many search results like some retard commercial. the same goes for matlab.
Title: Re: outline from gadient mask
Post by: yotamarker on April 27, 2017, 05:49:44 am
I have a question...
an image of 9 by 9 pixel has 512 possibilities ?
Title: Re: outline from gadient mask
Post by: yotamarker on April 27, 2017, 05:55:58 am
nope its 2^81
Title: Re: outline from gadient mask
Post by: korrelan on April 27, 2017, 10:55:16 am
Basic Feature Detection

With any kind of feature detection you are basically looking for a pattern within a pattern.

(http://i.imgur.com/0HGPvW1.jpg)

The simplest method is to apply a line/ outline convolution filter to your image and then search for known recognisable pixel patterns. The simplest pixel pattern is a 3x3 block (fig A); there are various ways of defining the block but the simplest is to assign a binary value to each surrounding pixel from X/Y.  So 20 using this encoding method would equal a P1/ top left right angle. 

This is the method I used do get the outlines of the shapes in this vid. Except I use the recognised binary shapes to move a point around a perimeter. I could easily mark the corners of shapes by noting the binary numbers for corners. Etc.

https://www.youtube.com/watch?v=o4FW-1xNbug (https://www.youtube.com/watch?v=o4FW-1xNbug)

A 5x5 (top right) or greater dimension block can be used but you would probably need a different encoding method; storing the pixel vector positions relative to the centre x,y as s simple list of vectors to be checked for example.

You then scan your image, summing the binary values of the surrounding pixels of each x,y point; the value returned can be easily checked against an array of known shapes (P1). Store the positions/ vectors in an array/ stack. This method is easy because you are just checking a one byte (0 to 255) value against a know array of byte/ shape values.

Shape Recognition

Once you have all the vectors for the found feature patterns and their relative positions to each other you can then find shapes (fig B) by checking for alignments etc.

Eigen Vectors

This is another method for checking one pattern against another without using an outline convolution filter; though usually a contrast filter is applied to bring the values of the image being checked in line with our set of eigen features

The RGB or Greyscale values of the surrounding pixels of the x,y point being scanned are subtracted from the pixel values being checked and run through a linear distance formula to see how similar they are. Rather than a simple binary array of numbers to check against; it uses small shaded bitmaps similar to (fig A top right).

‘s1=greyscale for position 1 (on binary grid above)
‘c1=greyscale for position 1 from the image being checked.

.v1=s1-c1
‘do same for all nine surrounding pixels storing V#

.dist=SQR((v1*v1)+(v2*v2)+(V3+… for all nine surrounding pixels.

The dist returned is a measure of how similar the block of pixels being checked is to the block of pixels in our stored array of eigen corner shapes.

http://www.wikihow.com/Find-the-Distance-Between-Two-Points (http://www.wikihow.com/Find-the-Distance-Between-Two-Points)

This method has the advantage that ‘eyes/ mouths’ can be defined as small blocks of pixels that can be checked against an image.

Motion Detection/ Optical Flow

If you have the relative positions for known eigen features within an image you can check them against the next image in the video stream and measure the displacement to log what’s moved/ how far and how fast.

Other Methods

There a loads of other methods or finding corners/ features in images. You could for example detect pixel changes around a circumference from your x, y scan point (fig C) using the relative angles to find corners.

You could use the binary method to get a rough idea where the corners are and then apply a more precise method to each found vector to weed out false positives.

My Method

Because my AGI is based on the human connectome/ nervous system I use a model of the human visual system to detect features.

https://www.youtube.com/watch?v=TYUu78-3wFk (https://www.youtube.com/watch?v=TYUu78-3wFk)

Neurons in the AGI’s visual cortex become trained to recognise lines/ corners etc through experience and only fire when their receptive fields detect their chosen pattern of inputs.  This is like running several convolution filters at once as scale/ rotation invariance/ gradients and movement can all be learned by the same V! cortex model.

:)
Title: Re: outline from gadient mask
Post by: yotamarker on April 27, 2017, 04:40:53 pm
so what would be the difference between 3X3 and 5X5 corners ?
Title: Re: outline from gadient mask
Post by: yotamarker on April 27, 2017, 04:50:32 pm
also I don't understand how you separated the shapes
Title: Re: outline from gadient mask
Post by: keghn on April 27, 2017, 06:53:29 pm
 A 5x5 pixel would be be more easy to see from the background noise.

 There are number of ways of getting an edge. But NN cut the picture up in squares:

http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/alg.html (http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/alg.html)

 in this overly super simplified example.

 On the fist level the colors are averaged out in each square. On the next level square are compared to another near by
squares, using XOR logic. IF there is a difference between the two then there is line or contour there that belong to
a outline.

 Big the squares the more it does auto blurring.

 There are other methods the use are kenel.
 Finding the Edges, The Sobel Operator: 
https://www.youtube.com/watch?v=uihBwtPIBxM (https://www.youtube.com/watch?v=uihBwtPIBxM)

 

Title: Re: outline from gadient mask
Post by: yotamarker on April 27, 2017, 08:44:57 pm
Code: [Select]
I never understand what those computerphiles try to explain.

is this the list of corner possibilities ? :

code]Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        'Dim i As Integer = 512
        'Dim s As String = Convert.ToString(i, 2).PadLeft(9, "0"c) '32 bits
        Dim str1 As String = ""
        Dim x As Integer = 0
        For index = 0 To 255
            str1 = Convert.ToString(index, 2).PadLeft(9, "0"c)
            x = str1.Substring(4, 1)
            If x = 1 Then
                TextBox1.Text &= str1.Substring(0, 3) & Environment.NewLine
                TextBox1.Text &= str1.Substring(3, 3) & Environment.NewLine
                TextBox1.Text &= str1.Substring(6, 3) & Environment.NewLine
                TextBox1.Text &= Environment.NewLine
            End If

        Next
    End Sub
End Class
Title: Re: outline from gadient mask
Post by: korrelan on April 27, 2017, 10:59:07 pm
(http://i.imgur.com/RKEgBrM.jpg)

Code: [Select]
10000000
01000000
11000000
00100000
10100000
01100000
11100000
00010000
10010000
01010000
11010000
00110000
10110000
01110000
11110000
00001000
10001000
01001000
11001000
00101000
10101000
01101000
11101000
00011000
10011000
01011000
11011000
00111000
10111000
01111000
11111000
00000100
10000100
01000100
11000100
00100100
10100100
01100100
11100100
00010100
10010100
01010100
11010100
00110100
10110100
01110100
11110100
00001100
10001100
01001100
11001100
00101100
10101100
01101100
11101100
00011100
10011100
01011100
11011100
00111100
10111100
01111100
11111100
00000010
10000010
01000010
11000010
00100010
10100010
01100010
11100010
00010010
10010010
01010010
11010010
00110010
10110010
01110010
11110010
00001010
10001010
01001010
11001010
00101010
10101010
01101010
11101010
00011010
10011010
01011010
11011010
00111010
10111010
01111010
11111010
00000110
10000110
01000110
11000110
00100110
10100110
01100110
11100110
00010110
10010110
01010110
11010110
00110110
10110110
01110110
11110110
00001110
10001110
01001110
11001110
00101110
10101110
01101110
11101110
00011110
10011110
01011110
11011110
00111110
10111110
01111110
11111110
00000001
10000001
01000001
11000001
00100001
10100001
01100001
11100001
00010001
10010001
01010001
11010001
00110001
10110001
01110001
11110001
00001001
10001001
01001001
11001001
00101001
10101001
01101001
11101001
00011001
10011001
01011001
11011001
00111001
10111001
01111001
11111001
00000101
10000101
01000101
11000101
00100101
10100101
01100101
11100101
00010101
10010101
01010101
11010101
00110101
10110101
01110101
11110101
00001101
10001101
01001101
11001101
00101101
10101101
01101101
11101101
00011101
10011101
01011101
11011101
00111101
10111101
01111101
11111101
00000011
10000011
01000011
11000011
00100011
10100011
01100011
11100011
00010011
10010011
01010011
11010011
00110011
10110011
01110011
11110011
00001011
10001011
01001011
11001011
00101011
10101011
01101011
11101011
00011011
10011011
01011011
11011011
00111011
10111011
01111011
11111011
00000111
10000111
01000111
11000111
00100111
10100111
01100111
11100111
00010111
10010111
01010111
11010111
00110111
10110111
01110111
11110111
00001111
10001111
01001111
11001111
00101111
10101111
01101111
11101111
00011111
10011111
01011111
11011111
00111111
10111111
01111111
11111111

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on April 28, 2017, 02:32:51 pm
your eye was so cool I had to copy it
Code: [Select]
Imports System.Math
Imports WindowsApp1.rinegan

Public Class Form1
    Dim eye1 As New Aeye()
    Dim checked As New List(Of Point)
    Dim b1 As Boolean = False
    Dim b2 As Boolean = False
    Dim b3 As Boolean = False
    Dim b4 As Boolean = False
    Dim b5 As Boolean = False
    Dim b6 As Boolean = False
    Dim b7 As Boolean = False
    Dim b8 As Boolean = False

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim bmp As New Bitmap("c:\testimage\x2.bmp")
        Dim x As Integer
        Dim y As Integer
        x = TextBox1.Text
        y = TextBox2.Text
        If Aeye.isOutLine(x, y, bmp, 20) Then
            corn(x, y, bmp)
        End If
        For Each item As Point In checked
            bmp = Aeye.mark_dark_pixel(item.X, item.Y, bmp, 1)
        Next

        'bmp = Aeye.mark_dark_pixelRED(x, y, bmp, 5)


        PictureBox2.Image = bmp.Clone()

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim bmp As New Bitmap("c:\testimage\x1.bmp")
        PictureBox1.Image = bmp.Clone()
    End Sub
    Sub corn(x As Integer, y As Integer, bmp As Bitmap)
        If Not checked.Contains(New Point(x, y)) Then
            checked.Add(New Point(x, y))
            b1 = Aeye.isOutLine(x - 1, y - 1, bmp, 20)
            b2 = Aeye.isOutLine(x - 1, y, bmp, 20)
            b3 = Aeye.isOutLine(x - 1, y + 1, bmp, 20)
            b4 = Aeye.isOutLine(x, y - 1, bmp, 20)
            b5 = Aeye.isOutLine(x + 1, y - 1, bmp, 20)
            b6 = Aeye.isOutLine(x + 1, y, bmp, 20)
            b7 = Aeye.isOutLine(x + 1, y + 1, bmp, 20)
            b8 = Aeye.isOutLine(x, y + 1, bmp, 20)
            If Not (b1 And b2 And b3 And b4 And b5 And b6 And b7 And b8) Then
                If b1 Then
                    corn(x - 1, y - 1, bmp)
                End If
                If b2 Then
                    corn(x - 1, y, bmp)
                End If
                If b3 Then
                    corn(x - 1, y + 1, bmp)
                End If
                If b4 Then
                    corn(x, y - 1, bmp)
                End If
                If b5 Then
                    corn(x + 1, y - 1, bmp)
                End If
                If b6 Then
                    corn(x + 1, y, bmp)
                End If
                If b7 Then
                    corn(x + 1, y + 1, bmp)
                End If
                If b8 Then
                    corn(x - 1, y + 1, bmp)
                End If
            End If

        End If
    End Sub
End Class
it still needs work but It has a "pupil" tell me what you think
Title: Re: outline from gadient mask
Post by: keghn on April 28, 2017, 04:47:29 pm
http://www.dailymail.co.uk/news/article-4450648/Madeleine-McCann-FACEBOOK.html (http://www.dailymail.co.uk/news/article-4450648/Madeleine-McCann-FACEBOOK.html)


http://www.dailymail.co.uk/sciencetech/article-4453610/What-color-background-optical-illusion.html (http://www.dailymail.co.uk/sciencetech/article-4453610/What-color-background-optical-illusion.html)
Title: Re: outline from gadient mask
Post by: yotamarker on April 29, 2017, 03:06:48 am
I have zero intention to white knight for this Madeleine McCann.
MGTOW MGTOW MGTOW !
Title: Re: outline from gadient mask
Post by: keghn on April 29, 2017, 03:19:14 pm
AI Learns Geometric Descriptors From Depth Images | Two Minute Papers: 


https://www.youtube.com/watch?v=1U3YKnuMS7g (https://www.youtube.com/watch?v=1U3YKnuMS7g)
Title: Re: outline from gadient mask
Post by: yotamarker on April 29, 2017, 06:16:23 pm
its truly amazing how lame current image processing walkthroughs are, well where are those source codes he's talking about ?
Title: Re: outline from gadient mask
Post by: keghn on May 01, 2017, 06:42:45 pm
A friendly introduction to Convolutional Neural Networks and Image Recognition: 

https://www.youtube.com/watch?v=2-Ol7ZB0MmU (https://www.youtube.com/watch?v=2-Ol7ZB0MmU)
Title: Re: outline from gadient mask
Post by: yotamarker on May 01, 2017, 07:47:46 pm
are u suggesting I use convolution for recognizing the corners ?
Title: Re: outline from gadient mask
Post by: yotamarker on May 02, 2017, 08:09:17 am
this week I have been trying to get all the images not including the encapsulated images in the picture
using the last code I posted , it has been so difficult I name the text files of the code versions hell#
yesterday my vision began to blur after about 7 hours, I think. it looks like I solved another puzzle though I have an idea for speeding it up a bit. after which I will look for a patch to get the inner images like in a picture of the rinegan
or rings of a tree bark.
Title: Re: outline from gadient mask
Post by: yotamarker on May 02, 2017, 09:31:55 am
it works great for the handicap sign but with real world images it gives terrible results with too long process time
and stack over flow err
Title: Re: outline from gadient mask
Post by: yotamarker on May 02, 2017, 12:17:01 pm
(https://i.imgflip.com/1o9nad.jpg) (https://imgflip.com/i/1o9nad) (https://imgflip.com/memegenerator)
Aeye.getPixelColor(bmp.GetPixel(j, i).R, bmp.GetPixel(j, i).G, bmp.GetPixel(j, i).B) = "b"
Title: Re: outline from gadient mask
Post by: korrelan on May 03, 2017, 10:17:30 pm
I’m pretty sure I’ve mentioned before that the image you are using is… crap.

JPG compression anomalies/ artefacts are seriously skewing your results.  Just because you can’t see the compression anomalies doesn't mean the computer can’t. This is your image with the tone balance adjusted to highlight the problem.

(http://i.imgur.com/4vmIWaP.jpg)

Your stack overflow problem is because your arrays aren't big enough. Try checking before you define an area if it’s already been highlighted… or mark the original image with a unique colour when an area is selected/ defined… this can be checked for before you re-define the area again… stopping the looping cascade that’s causing an overflow.

It only takes a 10X100 pixel area to fill a 1000 dim vector array.

The ‘Blue Hadouken’ you’re code is selecting is 179x182 = 32.5K pixels if taken from the original image.

https://www.youtube.com/watch?v=xO9bCWtWE4U (https://www.youtube.com/watch?v=xO9bCWtWE4U)

Too select an object against a regular plain background your only interested in the area of pixels that stand out/ are significantly different from the background. You could even use a simple flood fill algorithm to find the area of the object and get its boundaries.

The routine in the above video notes any colour that is close/ similar to the colour under the mouse pointer.  This creates a mask and the pixel bot has been taught to trace the perimeter of the mask.

To help find faces etc with this technique you might also benefit from changing the colour model from RGB to HSL when selecting similar colours.

http://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/ (http://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/)

 :)
Title: Re: outline from gadient mask
Post by: keghn on May 03, 2017, 11:32:09 pm
 Seven hours is quite impressive. Make sure you get enough food and extra sleep and minimal amount of exercise to
stay health at this time. For your brain that is working like a champ.
 Me, talking as brain trainer. Your brain is many parts working together. If one part is in super mode other part may
work against you, like blurring and or unable to remember your train of thought on what your coding. This is to force you to become normal.
 If all brain parts working as one then reward them with extra calories and sleep.
 If all parts are fighting each other than do not give your self extra or calories and
only the minimal amount of sleep that a human needs to say health. And do extra physical exercise.
 When you young it hard to see this going on. But the older you get it can get really bad.

  cheers




Title: Re: outline from gadient mask
Post by: yotamarker on May 04, 2017, 06:51:13 am
yeah with the mouse it works but if you want all the images it glitches like crazy.
Code: [Select]
Imports System.Math
Imports WindowsApp1.rinegan

Public Class Form1
    Dim eye1 As New Aeye()
    Dim checked As New List(Of Point)
    Dim b1 As Boolean = False
    Dim b2 As Boolean = False
    Dim b3 As Boolean = False
    Dim b4 As Boolean = False
    Dim b5 As Boolean = False
    Dim b6 As Boolean = False
    Dim b7 As Boolean = False
    Dim b8 As Boolean = False
    Dim x As Integer
    Dim y As Integer
    Dim rList As New List(Of Rectangle)

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim bmp As New Bitmap("c:\testimage\x11.bmp")
        'Dim matrix(bmp.Width, bmp.Height) As Boolean
        'For i As Integer = 0 To bmp.Height - 1
        '    For j As Integer = 0 To bmp.Width - 1
        '        matrix(j, i) = Aeye.is_pixel_dark_at(j, i, bmp, 40)
        '        bmp = Aeye.mark_dark_pixel(j, i, bmp, 1)
        '    Next
        'Next
        Dim x As Integer
        Dim y As Integer
        x = TextBox1.Text
        y = TextBox2.Text
        Dim minx, miny, maxx, maxy As Integer
        minx = bmp.Width
        miny = bmp.Height
        maxx = 0
        maxy = 0
        Dim rec As New Rectangle()
        If Aeye.isOutLine(x, y, bmp, 20) Then
            corn(x, y, bmp)
            ' rectangle marker for the pixels of the shape detected by sub corn
            For Each item As Point In checked
                Aeye.maxer(item.X, maxx)
                Aeye.maxer(item.Y, maxy)
                Aeye.miner(item.X, minx)
                Aeye.miner(item.Y, miny)

            Next
            If maxx - minx > 10 And maxy - miny > 10 Then
                bmp = Aeye.graphicContour(bmp, minx, maxx, miny, maxy)
                TextBox3.Text &= minx.ToString & " " & miny.ToString & " " & maxx.ToString() & " " & maxy.ToString & Environment.NewLine
            End If
        End If
        'For Each item As Point In checked
        '    bmp = Aeye.mark_dark_pixel(item.X, item.Y, bmp, 1)
        'Next
        Dim bmp2 As New Bitmap(bmp)
        PictureBox3.Image = Aeye.mark_dark_pixelRED(x, y, bmp2, 5)

        checked.Clear()
        PictureBox2.Image = bmp.Clone()

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim bmp As New Bitmap("c:\testimage\x1.bmp")
        PictureBox1.Image = bmp.Clone()
    End Sub
    Sub corn(x As Integer, y As Integer, bmp As Bitmap)
        If Not checked.Contains(New Point(x, y)) Then
            checked.Add(New Point(x, y))
            b1 = Aeye.isOutLine(x - 1, y - 1, bmp, 20)
            b2 = Aeye.isOutLine(x - 1, y, bmp, 20)
            b3 = Aeye.isOutLine(x - 1, y + 1, bmp, 20)
            b4 = Aeye.isOutLine(x, y - 1, bmp, 20)
            b5 = Aeye.isOutLine(x + 1, y - 1, bmp, 20)
            b6 = Aeye.isOutLine(x + 1, y, bmp, 20)
            b7 = Aeye.isOutLine(x + 1, y + 1, bmp, 20)
            b8 = Aeye.isOutLine(x, y + 1, bmp, 20)
            If Not (b1 And b2 And b3 And b4 And b5 And b6 And b7 And b8) Then
                If b1 Then
                    corn(x - 1, y - 1, bmp)
                End If
                If b2 Then
                    corn(x - 1, y, bmp)
                End If
                If b3 Then
                    corn(x - 1, y + 1, bmp)
                End If
                If b4 Then
                    corn(x, y - 1, bmp)
                End If
                If b5 Then
                    corn(x + 1, y - 1, bmp)
                End If
                If b6 Then
                    corn(x + 1, y, bmp)
                End If
                If b7 Then
                    corn(x + 1, y + 1, bmp)
                End If
                If b8 Then
                    corn(x - 1, y + 1, bmp)
                End If
            End If

        End If
    End Sub
    Function listOfPointsToRectangle(ByVal lst As List(Of Point), ByVal bmp As Bitmap) As Rectangle
        Dim minx, miny, maxx, maxy As Integer
        minx = bmp.Width
        miny = bmp.Height
        maxx = 0
        maxy = 0
        For Each item As Point In lst
            Aeye.maxer(item.X, maxx)
            Aeye.maxer(item.Y, maxy)
            Aeye.miner(item.X, minx)
            Aeye.miner(item.Y, miny)

        Next
        Dim rec As New Rectangle(0, 0, 1000, 1000)
        If maxx - minx > 10 And maxy - miny > 10 Then
            rec = New Rectangle(minx, miny, maxx - minx, maxy - miny)
        End If

    End Function

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim bmp As New Bitmap("c:\testimage\x32.bmp")
        'x = 100
        'y = 112
        'xu()
        'x = 115
        'y = 100
        'xu()
        x = 2
        y = 2
        xu()
        x = 0
        Dim c As Integer = 2
        For i As Integer = 3 To bmp.Height - 2
            While c < bmp.Width - 5
                c += 1


                c += jumper(c, i)
                x = c
                y = i
                Try
                    If Aeye.is_pixel_dark_at(x, y, bmp, 50) Then

                        xu()
                    End If
                Catch ex As Exception

                End Try

                'xu()
            End While
            c = 2
        Next
    End Sub
    Sub xu()
        Dim bmp As New Bitmap("c:\testimage\x32.bmp")
        Dim minx, miny, maxx, maxy As Integer
        minx = bmp.Width
        miny = bmp.Height
        maxx = 0
        maxy = 0
        Dim rec As New Rectangle()
        If Aeye.isOutLine(x, y, bmp, 20) Then
            corn(x, y, bmp)
            ' rectangle marker for the pixels of the shape detected by sub corn
            For Each item As Point In checked
                Aeye.maxer(item.X, maxx)
                Aeye.maxer(item.Y, maxy)
                Aeye.miner(item.X, minx)
                Aeye.miner(item.Y, miny)

            Next
            Dim rTemp As New Rectangle(minx, miny, maxx - minx, maxy - miny)

            If maxx - minx > 10 And maxy - miny > 10 And Not rList.Contains(rTemp) Then
                'bmp = Aeye.graphicContour(bmp, minx, maxx, miny, maxy)
                rList.Add(rTemp)
                TextBox3.Text &= minx.ToString & " " & miny.ToString & " " & maxx.ToString() & " " & maxy.ToString & Environment.NewLine
            End If
        End If

        Dim bmp2 As New Bitmap(bmp)
        PictureBox3.Image = Aeye.mark_dark_pixelRED(x, y, bmp2, 5)

        checked.Clear()
        PictureBox2.Image = bmp.Clone()
    End Sub
    Function jumper(ByVal x As Integer, ByVal y As Integer) As Integer
        Dim ret As Integer = 0
        For Each item As Rectangle In rList
            If (x >= item.X And x <= item.Width + item.X) And (y >= item.Y And y <= item.Height + item.Y) Then
                ret = item.Width + item.X + 1
            End If
        Next
        Return ret
    End Function
End Class
Title: Re: outline from gadient mask
Post by: yotamarker on May 04, 2017, 06:58:17 am
the glitches are also mostly wrong captured overlapping area in a variety of real world images
Title: Re: outline from gadient mask
Post by: yotamarker on May 05, 2017, 01:21:02 am
see Reply #91 that's the pupil code I talk about , I need it to go through the entire picture to get all the objects and fast.
https://www.youtube.com/watch?v=ChrTqW1F3fU&feature=youtu.be (https://www.youtube.com/watch?v=ChrTqW1F3fU&feature=youtu.be)
Title: Re: outline from gadient mask
Post by: korrelan on May 05, 2017, 01:43:15 am
Earlier on in this thread I mentioned that you would have problems using outlines to recognise objects.
 
Can you see the sailing ship, Unicorn… and every other object known to man?

(http://i.imgur.com/4sbBkfe.png)

This is the problem with recognising objects by their outline… it’s a top down… bottom up problem… if you have no idea what you are looking for… how can you find it?

 :)
Title: Re: outline from gadient mask
Post by: Freddy on May 05, 2017, 01:59:26 am
Is that where the use of reference images come in ?

I'm thinking humans learn things that they see. But what I have seen so far seems to be 2D images being used. It's going to need something like an internal 3D model and texture to recognise things at different orientations me thinks.

Is there even the computer power to do that yet ?
Title: Re: outline from gadient mask
Post by: yotamarker on May 05, 2017, 02:46:15 am
I don't have a problem using outlines I have a problem using the method in reply 91 to get outlines.
Title: Re: outline from gadient mask
Post by: korrelan on May 05, 2017, 10:31:23 am
Post #91 has half the code missing. Ie isoutline()?

On an unrelated note… OMG what have Microsoft done to VB? Moving it over to a .NET object orientated language has not only made it extremely slow… but very hard to interoperate/ read lol.

 :)
Title: Re: outline from gadient mask
Post by: yotamarker on May 05, 2017, 01:45:58 pm
your need the eye class ?
Code: [Select]
Imports System.Math
Namespace rinegan
    Public Class Aeye
        Public outlinePixel As Integer = 30
        Dim Imageslist As New List(Of ImageList)
        Dim ImageListCounter As Integer = 0
        Dim minX, minY, maxX, maxY As Integer
        Dim checkedMatrix(2000, 2000) As Boolean
        Dim imageMatrix(2000, 2000) As Boolean
        Dim HX(1000) As Integer
        Dim LX(1000) As Integer
        Dim HY(1000) As Integer
        Dim LY(1000) As Integer
        Dim Icounter As Integer
        Public Shared Function is_pixel_dark_at(ByVal xPos As Integer, ByVal Ypos As Integer, ByVal image As Bitmap, ByVal DarkPixel As Integer) As Boolean
            Dim color As Color
            Dim r, g, b As Integer
            color = image.GetPixel(xPos, Ypos)
            r = color.R
            g = color.G
            b = color.B
            If (r < DarkPixel) And (g < DarkPixel) And (b < DarkPixel) Then
                Return True
            Else
                Return False
            End If
        End Function
        Public Shared Function isOutLine(ByVal xPos As Integer, ByVal Ypos As Integer, ByVal image As Bitmap, ByVal bias As Integer) As Boolean

            Dim result As Boolean = False
            Dim change As Byte = 0
            If xPos > 0 And xPos < image.Width - 1 And Ypos > 0 And Ypos < image.Height - 1 Then
                Dim color4, color5, color8 As Color
                'color1 = image.GetPixel(xPos - 1, Ypos - 1)
                'color2 = image.GetPixel(xPos, Ypos - 1)
                'color3 = image.GetPixel(xPos + 1, Ypos - 1)
                'color7 = image.GetPixel(xPos - 1, Ypos + 1)
                color8 = image.GetPixel(xPos, Ypos + 1)
                'color9 = image.GetPixel(xPos + 1, Ypos + 1)
                color4 = image.GetPixel(xPos - 1, Ypos)
                'color6 = image.GetPixel(xPos + 1, Ypos)
                color5 = image.GetPixel(xPos, Ypos)

                If (CType(color5.R, Integer) > CType(color4.R, Integer) - bias) And (CType(color5.R, Integer) < CType(color4.R, Integer) + bias) Then
                    change += 1

                End If
                If (CType(color5.G, Integer) > CType(color4.G, Integer) - bias) And (CType(color5.G, Integer) < CType(color4.G, Integer) + bias) Then
                    change += 1

                End If
                If (CType(color5.B, Integer) > CType(color4.B, Integer) - bias) And (CType(color5.B, Integer) < CType(color4.B, Integer) + bias) Then
                    change += 1

                End If
                If (CType(color5.R, Integer) > CType(color8.R, Integer) - bias) And (CType(color5.R, Integer) < CType(color8.R, Integer) + bias) Then
                    change += 1

                End If
                If (CType(color5.G, Integer) > CType(color8.G, Integer) - bias) And (CType(color5.G, Integer) < CType(color8.G, Integer) + bias) Then
                    change += 1

                End If
                If (CType(color5.B, Integer) > CType(color8.B, Integer) - bias) And (CType(color5.B, Integer) < CType(color8.B, Integer) + bias) Then
                    change += 1

                End If
            End If


            If change = 6 Then
                result = True
            End If
            Return result
        End Function
        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
                For j As Integer = 0 To marker
                    Try
                        bmp1.SetPixel(x + j, y + i, Color.Green)
                    Catch ex As Exception

                    End Try
                Next
            Next
            Return bmp1

        End Function
        Public Shared Function getPixelColor(ByVal r As Integer, ByVal g As Integer, ByVal b As Integer) As Char
            ' r= red, g = green, b = blue
            Dim colorchar As Char
            If r > 245 And g > 245 And b > 245 Then
                colorchar = "w" ' white
            ElseIf r < 20 And g < 20 And b < 20 Then
                colorchar = "k" ' black (kuro in japanese)
            ElseIf r > g And g > b And g < 100 Then
                colorchar = "r" ' red
            ElseIf r > g And g > b And g > 200 Then
                colorchar = "y" ' yellow
            ElseIf r > g And g > b And 100 < g < 200 Then
                colorchar = "o" 'orange
            ElseIf (g > r And r > b) Or (g > b And b > r) Then
                colorchar = "g" 'green
            ElseIf b > g And g > r Then
                colorchar = "b" 'blue
            ElseIf (b > r And r > g) Or (r > b And g < 20) Then
                colorchar = "v" ' violet
            Else
                colorchar = "u" ' yet undefined
            End If
            Return colorchar
        End Function
        Public Shared Function mark_dark_pixelRED(ByVal x As Integer, ByVal y As Integer, ByVal bmp1 As Bitmap, ByVal marker As Byte)
            For i As Integer = 0 To marker
                For j As Integer = 0 To marker
                    Try
                        bmp1.SetPixel(x + j, y + i, Color.Red)
                    Catch ex As Exception

                    End Try
                Next
            Next
            Return bmp1

        End Function
        Public Shared Function mark_dark_pixelBlue(ByVal x As Integer, ByVal y As Integer, ByVal bmp1 As Bitmap, ByVal marker As Byte)
            For i As Integer = 0 To marker
                For j As Integer = 0 To marker
                    Try
                        bmp1.SetPixel(x + j, y + i, Color.Blue)
                    Catch ex As Exception

                    End Try
                Next
            Next
            Return bmp1

        End Function
        'Public Function contourImage(ByVal bmp As Bitmap) As Bitmap

        '    For index = 0 To bmp.Height - 1
        '        For j = 0 To bmp.Width - 1
        '            checkedMatrix(j, index) = False
        '            imageMatrix(j, index) = is_pixel_dark_at(j, index, bmp, 30)
        '            'If imageMatrix(j, index) Then
        '            '    MsgBox(j, index)
        '            'End If
        '        Next

        '    Next
        '    minX = bmp.Width
        '    minY = bmp.Height
        '    maxX = 0
        '    maxY = 0
        '    Dim jindex As Integer = 0
        '    Icounter = 0
        '    For i = 0 To bmp.Height - 1 Step 5

        '        While jindex < bmp.Width - 1
        '            If Not checkedMatrix(jindex, i) Then
        '                If Not imageMatrix(jindex, i) Then
        '                    checkedMatrix(jindex, i) = True
        '                Else
        '                    tracer(bmp, bmp.Width, bmp.Height, jindex, i)
        '                    HX(Icounter) = maxX
        '                    LX(Icounter) = minX
        '                    HY(Icounter) = maxY
        '                    LY(Icounter) = minY
        '                    Icounter += 1
        '                    minX = bmp.Width
        '                    minY = bmp.Height
        '                    maxX = 0
        '                    maxY = 0
        '                    jindex = jumpImage(jindex, i)
        '                End If
        '            End If



        '            jindex += 1
        '        End While
        '        jindex = 0
        '    Next

        '    For index = 0 To Icounter
        '        bmp = graphicContour(bmp, LX(index), HX(index), LY(index), HY(index))
        '    Next

        '    Return bmp

        'End Function
        Public Function jumpImage(ByVal x, y) As Integer
            If Icounter > 999 Then
                Icounter = 999
            End If
            Dim n As Integer = 0
            For index = 0 To Icounter
                If (LX(index) <= x And HX(index) >= x) And (LY(index) <= y And HY(index) >= y) Then
                    n = HX(index)
                End If
            Next
            Return n
        End Function
        Public Shared Function graphicContour(ByVal bmp As Bitmap, ByVal xmin As Integer, ByVal xmax As Integer, ByVal ymin As Integer, ByVal ymax As Integer) As Bitmap
            For i = xmin To xmax
                bmp = mark_dark_pixel(i, ymin, bmp, 1)
                bmp = mark_dark_pixel(i, ymax, bmp, 1)
            Next
            For i = ymin To ymax
                bmp = mark_dark_pixel(xmin, i, bmp, 1)
                bmp = mark_dark_pixel(xmax, i, bmp, 1)
            Next
            Return bmp
        End Function
        Public Shared Function graphicContourRed(ByVal bmp As Bitmap, ByVal xmin As Integer, ByVal xmax As Integer, ByVal ymin As Integer, ByVal ymax As Integer) As Bitmap
            For i = xmin To xmax
                bmp = mark_dark_pixelRED(i, ymin, bmp, 1)
                bmp = mark_dark_pixelRED(i, ymax, bmp, 1)
            Next
            For i = ymin To ymax
                bmp = mark_dark_pixelRED(xmin, i, bmp, 1)
                bmp = mark_dark_pixelRED(xmax, i, bmp, 1)
            Next
            Return bmp
        End Function
        Public Shared Function graphicContourBlue(ByVal bmp As Bitmap, ByVal xmin As Integer, ByVal xmax As Integer, ByVal ymin As Integer, ByVal ymax As Integer) As Bitmap
            For i = xmin To xmax
                bmp = mark_dark_pixelBlue(i, ymin, bmp, 1)
                bmp = mark_dark_pixelBlue(i, ymax, bmp, 1)
            Next
            For i = ymin To ymax
                bmp = mark_dark_pixelBlue(xmin, i, bmp, 1)
                bmp = mark_dark_pixelBlue(xmax, i, bmp, 1)
            Next
            Return bmp
        End Function
        'Private Sub tracer(ByVal bmp1 As Bitmap, ByVal w1 As Integer, ByVal h1 As Integer, ByVal x As Integer, ByVal y As Integer)
        '    If (x > 0 And x < w1) And (y > 0 And y < h1) Then
        '        If Not checkedMatrix(x, y) Then
        '            checkedMatrix(x, y) = True
        '            If imageMatrix(x, y) Then 'not black pixel
        '                maxer(x, maxX)
        '                maxer(y, maxY)
        '                miner(x, minX)
        '                miner(y, minY)
        '                tracer(bmp1, w1, h1, x - 1, y - 1)
        '                tracer(bmp1, w1, h1, x, y - 1)
        '                tracer(bmp1, w1, h1, x + 1, y - 1)
        '                tracer(bmp1, w1, h1, x - 1, y)
        '                tracer(bmp1, w1, h1, x + 1, y)
        '                tracer(bmp1, w1, h1, x - 1, y + 1)
        '                tracer(bmp1, w1, h1, x, y + 1)
        '                'tracer(bmp1, w1, h1, x + 1, y + 1)
        '            End If
        '        End If
        '    End If
        'End Sub
        Public Shared Sub maxer(ByVal a As Integer, ByRef b As Integer)
            If a > b Then
                b = a
            End If
        End Sub
        Public Shared Sub miner(ByVal a As Integer, ByRef b As Integer)
            If a < b Then
                b = a
            End If
        End Sub

    End Class
    Public Class ImageList
        Public minX As Integer
        Public minY As Integer
        Public maxX As Integer
        Public maxY As Integer
    End Class
End Namespace

Title: Re: outline from gadient mask
Post by: yotamarker on May 11, 2017, 07:38:00 pm
https://www.youtube.com/watch?v=A6kUWXbVOvQ (https://www.youtube.com/watch?v=A6kUWXbVOvQ)
Title: Re: outline from gadient mask
Post by: keghn on May 12, 2017, 02:08:55 pm
 




    Cool



Title: Re: outline from gadient mask
Post by: yotamarker on May 18, 2017, 07:48:55 pm
https://www.youtube.com/watch?v=hNcYQemcbKs (https://www.youtube.com/watch?v=hNcYQemcbKs)
Title: Re: outline from gadient mask
Post by: yotamarker on May 18, 2017, 08:14:58 pm
(https://i.imgflip.com/1pah3v.jpg) (https://imgflip.com/i/1pah3v) (https://imgflip.com/memegenerator)
Title: Re: outline from gadient mask
Post by: yotamarker on May 18, 2017, 09:09:46 pm
https://www.youtube.com/watch?v=ArZHiFAFvRo (https://www.youtube.com/watch?v=ArZHiFAFvRo)
Title: Re: outline from gadient mask
Post by: yotamarker on May 20, 2017, 11:45:05 am
(https://i.imgflip.com/1pe6w6.jpg) (https://imgflip.com/i/1pe6w6) (https://imgflip.com/memegenerator)
Title: Re: outline from gadient mask
Post by: yotamarker on May 20, 2017, 01:38:02 pm
(https://i.imgflip.com/1peacy.jpg) (https://imgflip.com/i/1peacy) (https://imgflip.com/memegenerator)
Title: Re: outline from gadient mask
Post by: keghn on May 21, 2017, 06:33:58 pm
 Very nice.
 I have been thinking about descriptors lately for that right angle triangle you are using for testing.
 I thinking a self comparative ration  descriptor table would be used: 

http://www.mathwarehouse.com/geometry/triangles/right-triangles/images/picture-30-60-90-special-right-triangle.png (http://www.mathwarehouse.com/geometry/triangles/right-triangles/images/picture-30-60-90-special-right-triangle.png)

 This is so you can identify same triangle up close or far away.

Fragment of  curves can haver ratio. These two chain codes are 25 percent of a circumference of a circle. But one is twice as big:

 30 degrees to the next pixel, 30 degrees, 30 degrees, = 90 and this is the small circle fragment.
15 degrees, 15 degrees, 15 degrees, 15 degrees, 15 degrees, 15 degrees = 90 degrees and is 25 percent ratio.
Both curve have are equal ratios. So when you zoom in out in a video you can identify thing of different sizes.

 A face will be made up of a combination of straight lines and curves: 

https://www.google.com/imgres?imgurl=http%3A%2F%2Fwww.the.me%2Fwp-content%2Fuploads%2F2014%2F08%2Fstory_lena_lenna_2.jpg&imgrefurl=https%3A%2F%2Fthe.me%2Fthe-story-of-lena%2F&docid=-tlZabWNRupR1M&tbnid=WKb0ThKcPJeD4M%3A&vet=10ahUKEwj3gfjgwIHUAhUT32MKHe8vA_MQMwg0KA8wDw..i&w=590&h=295&bih=631&biw=1216&q=image%20of%20edge%20detection%20of%20a%20woman&ved=0ahUKEwj3gfjgwIHUAhUT32MKHe8vA_MQMwg0KA8wDw&iact=mrc&uact=8#h=295&imgdii=pTf4RqToac6RVM:&vet=10ahUKEwj3gfjgwIHUAhUT32MKHe8vA_MQMwg0KA8wDw..i&w=590 (https://www.google.com/imgres?imgurl=http%3A%2F%2Fwww.the.me%2Fwp-content%2Fuploads%2F2014%2F08%2Fstory_lena_lenna_2.jpg&imgrefurl=https%3A%2F%2Fthe.me%2Fthe-story-of-lena%2F&docid=-tlZabWNRupR1M&tbnid=WKb0ThKcPJeD4M%3A&vet=10ahUKEwj3gfjgwIHUAhUT32MKHe8vA_MQMwg0KA8wDw..i&w=590&h=295&bih=631&biw=1216&q=image%20of%20edge%20detection%20of%20a%20woman&ved=0ahUKEwj3gfjgwIHUAhUT32MKHe8vA_MQMwg0KA8wDw&iact=mrc&uact=8#h=295&imgdii=pTf4RqToac6RVM:&vet=10ahUKEwj3gfjgwIHUAhUT32MKHe8vA_MQMwg0KA8wDw..i&w=590)
Title: Re: outline from gadient mask
Post by: yotamarker on May 21, 2017, 07:42:32 pm
to recog shapes I was thinking :
get a list of corner types, at any rate I don't think the size would cause much of a difference, as long as I sample
a consistent amount of pixels.
Title: Re: outline from gadient mask
Post by: keghn 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)
Title: Re: outline from gadient mask
Post by: yotamarker on May 26, 2017, 10:01:54 pm
https://www.youtube.com/watch?v=poA6-5rQsaw (https://www.youtube.com/watch?v=poA6-5rQsaw)
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 ?
Title: Re: outline from gadient mask
Post by: keghn on May 28, 2017, 08:48:36 pm
Intro to Algorithms: Crash Course Computer Science #13: 

https://www.youtube.com/watch?v=rL8X2mlNHPM (https://www.youtube.com/watch?v=rL8X2mlNHPM)
Title: Re: outline from gadient mask
Post by: yotamarker 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.
Title: Re: outline from gadient mask
Post by: keghn 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.
Title: Re: outline from gadient mask
Post by: yotamarker on May 30, 2017, 01:55:29 pm
would a stronger computer result in the algorithm running faster ?
Title: Re: outline from gadient mask
Post by: korrelan on May 31, 2017, 10:01:54 am
https://blog.athelas.com/a-brief-history-of-cnns-in-image-segmentation-from-r-cnn-to-mask-r-cnn-34ea83205de4

 :)
Title: Re: outline from gadient mask
Post by: keghn 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.


Title: Re: outline from gadient mask
Post by: korrelan 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.

 :)
Title: Re: outline from gadient mask
Post by: keghn on June 10, 2017, 07:06:26 pm
Gauss's magic shoelace area formula and its calculus companion: 

https://www.youtube.com/watch?v=0KjG8Pg6LGk (https://www.youtube.com/watch?v=0KjG8Pg6LGk)
Title: Re: outline from gadient mask
Post by: yotamarker on June 11, 2017, 10:41:00 pm
https://www.youtube.com/watch?v=btW8lYcb3tQ&t=131s (https://www.youtube.com/watch?v=btW8lYcb3tQ&t=131s)
Title: Re: outline from gadient mask
Post by: yotamarker on June 28, 2017, 06:24:21 pm
(https://i.imgflip.com/1rntp0.jpg) (https://imgflip.com/i/1rntp0) (https://imgflip.com/memegenerator)

 if it analyzes 0.25 of the image at a time with the times 3 speed up algorithm it runs 12 times faster which is under a second for images 2500 over 1500 pixels with a medium computer that 2017 has to offer.
Title: Re: outline from gadient mask
Post by: yotamarker on June 28, 2017, 06:37:10 pm
https://www.youtube.com/watch?v=7KL0EXpwPAM
sped up : times 1, times 10, times 5
Title: Re: outline from gadient mask
Post by: yotamarker on June 29, 2017, 08:49:00 pm
(https://i.imgflip.com/1rqdjq.jpg) (https://imgflip.com/i/1rqdjq) (https://imgflip.com/memegenerator)
Title: Re: outline from gadient mask
Post by: yotamarker on June 29, 2017, 08:52:42 pm
please post classifier suggestions for image recognition.
Title: Re: outline from gadient mask
Post by: keghn on June 30, 2017, 04:27:49 am
 Here are four: 
1). k nearest Neighbor: 
?????? 

2). k means : 
main classification is in the middle of a cluster. 
https://www.youtube.com/watch?v=7Qv0cmJ6FsI 
https://www.youtube.com/watch?v=mE7MWa6N2Vc 
https://www.youtube.com/watch?v=gS0L2R6mqPE&index=5&list=PLHAGtYBohmIFCxJXH1MCydMdNY8JMx9MO 

3). Cascade Classification, Haar: 
http://docs.opencv.org/2.4/modules/objdetect/doc/cascade_classification.html   
 
4). Neural Networks: 
????????? 
Title: Re: outline from gadient mask
Post by: keghn on July 05, 2017, 09:24:58 pm
The Curse of Dimensionality in classification: 

http://www.visiondummy.com/2014/04/curse-dimensionality-affect-classification/
Title: Re: outline from gadient mask
Post by: yotamarker on July 05, 2017, 10:54:30 pm
interesting read, at any rate it seems unlikely to me that nature uses something that complex.
Title: Re: outline from gadient mask
Post by: korrelan on July 05, 2017, 11:24:25 pm
@Keghn...I'm pleased he realised/ stated...

Quote
In fact, this depends on the amount of training data available, the complexity of the decision boundaries, and the type of classifier used.

If the theoretical infinite number of training samples would be available, the curse of dimensionality does not apply and we could simply use an infinite number of features to obtain perfect classification.

 :)
Title: Re: outline from gadient mask
Post by: keghn on July 06, 2017, 12:29:53 am
 I have giving it thought about making it work in  x, y, z dimensions. Such as they do with PCA and t-SNE mapping. 

 With every object having their features. Each feature and sub feature is a dimension. Such as a outline of a box. That has four corners and four edges which has eight dimensions. 
 The flower tutorial above was nice. it only have two dimensions. 

 But the way i am dealing with it, in this universe, is to pair all features and sub features with weight. The weight is A value 
multiplied to a sub feature. It is initially set to one.   

 Now for example, you have two objects  and each object is described by its sub features, such as 
corners and straight edges of length, and curved line of length. 
 Then to find the distance in n space is to select one object and start increasing or decreasing weight until it become the 
other object. 

 The amount of change it to the weight is "the DISTANCE". 

 With million and billion of objects in this world, it is more like of being a hyper space pilot and selecting a conduit to another
object. 
 And when you do move keep track of what you moving away from and what you are move to. There is no x, y, and z here it is
relative relation with each other objects. Like the mother nature does it.

 But there are trick to view it in flat space.
PCA: 
https://en.wikipedia.org/wiki/Principal_component_analysis 

http://ccwu.me/vsfm/ 


t-SNE: 
https://www.youtube.com/watch?v=RJVL80Gg3lA


Title: Re: outline from gadient mask
Post by: yotamarker on July 08, 2017, 06:39:53 am
https://www.youtube.com/watch?v=FPqmRNXsfvw
Title: Re: outline from gadient mask
Post by: yotamarker on July 14, 2017, 04:46:42 pm
I want the alg that makes the optical mouse detect if it was moved left or right
Title: Re: outline from gadient mask
Post by: keghn on July 14, 2017, 06:24:42 pm
 This total software problem. it would have to built out of something that would get the mouse position. That is if
you are using visual basic?:

Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
    Dim MPx As Point = MousePosition()
    TextBox1.Text = MPx.ToString

End Sub


Title: Re: outline from gadient mask
Post by: yotamarker on July 14, 2017, 07:25:21 pm
no I was talking about image motion direction recognition, I thought about using the mouse's  algorithm to solve it.
I found no proper walkthrough online so I figured it out myself, but the thing was that alg is only accurate as long as
the whole image moves so I modified it, I'LL upload some vids sooner than later, thanks.
Title: Re: outline from gadient mask
Post by: yotamarker on July 15, 2017, 07:33:30 am
1st time I used static dim  8)
Title: Re: outline from gadient mask
Post by: yotamarker on July 17, 2017, 08:33:25 pm
https://www.youtube.com/watch?v=DDV1c9QzxfQ
Title: Re: outline from gadient mask
Post by: keghn on July 18, 2017, 07:42:35 pm

AMD Threadripper—16 cores and 32 threads for $999–arrives in August:   

https://arstechnica.com/gadgets/2017/07/amd-threadripper-16-cores-and-32-threads-for-999-arrives-in-august/



Title: Re: outline from gadient mask
Post by: yotamarker on July 18, 2017, 09:48:39 pm
the direction getter code itself is actually 10000 times faster then the image recognition
Title: Re: outline from gadient mask
Post by: yotamarker on July 18, 2017, 09:52:22 pm
when I speed up the image recog some objects aren't fully detected like the circle is detected as two half circles
Title: Re: outline from gadient mask
Post by: keghn on July 18, 2017, 11:19:16 pm
In the math are you using the length of curve and the chord length?
 If so then curve length is an arc of 70 degrees then it's mirror would be 190 degrees or other
wise of putting it 70 and -70 degree: 

https://www.ck12.org/trigonometry/Length-of-a-Chord/lesson/Length-of-a-Chord-TRIG/
Title: Re: outline from gadient mask
Post by: yotamarker on July 19, 2017, 04:20:39 am
what math what are you talking about ?
Title: Re: outline from gadient mask
Post by: yotamarker on July 19, 2017, 06:41:24 pm
what else does an eye do ?
count
recog objects
read
recog movements
recog colors
recog shapes (edges)
recog grids
recog size and distances

(https://i.imgflip.com/1sr142.jpg) (https://imgflip.com/i/1sr142) (https://imgflip.com/memegenerator)
Title: Re: outline from gadient mask
Post by: keghn on July 19, 2017, 07:12:09 pm
 The edges between chaos and low chaos. Such as shore line of a rough river.
 The edges between simple and complexity. The sky and the leaves in the tree or the face and the heir line.
 Two very stable patches of color with a chaotic edge dancing some where in between.
  In brace the chaos.
Title: Re: outline from gadient mask
Post by: yotamarker on July 19, 2017, 10:41:29 pm
I"ll throw an Idea I just had, and you guys tell me what you think :
what if I limit the processing area to the region of move area, with the addition of processing the whole image if she is static (no movement) ?

BTW, I eat bananas !
Title: Re: outline from gadient mask
Post by: keghn on July 23, 2017, 07:18:18 pm
  That should work find.
 A AGI brain "main tracking routine" figures out what to track. The simple static stuff or non moving stuff is found first and
then is given to a different a "simple tracking subroutine" to be track in low detail.

 The "main tracking routine" track things that need a lot of CPU processing power. It needs 10 threads out of 18.
 There is only one "Main tracking routine".
 There can be up to twenty "simple tracking routines". And all twenty may share one or two threads.

 When a "simple tracking routine" finds that is is losing control it calls for the "Main tracking routine" to take over.

 The main tracing is conscious mind.
 The "simple robotic tracking" is subconscious mind.

Title: Re: outline from gadient mask
Post by: yotamarker on July 23, 2017, 09:07:22 pm
I gave it some more thought and there is a problem :
you don't get additional object near data, so if you see a fire hydrant and you don't see the kiosk next to it
you can't know specifically enough where you are.