Code Monkey home page Code Monkey logo

Comments (6)

luispedro avatar luispedro commented on May 31, 2024

It's not, at the moment, a priority for me (although I would gladly accept a patch), but I will leave the issue open for future reference.

from mahotas.

jasson2001 avatar jasson2001 commented on May 31, 2024

Mr luispedro 👍
Frist , thank you for your excellent work! I am very glad to join your project!
Recently, I help a kindly friend to do some thing- Hough transforms , using in detect line in a image,
Could I pull my code? Can you interview my code?
Thank you again!

from mahotas.

jasson2001 avatar jasson2001 commented on May 31, 2024

import math
import mahotas as mh
import mahotas.demos
import numpy as np
import pylab as plt
import matplotlib
matplotlib.use('TkAgg')

import pylab

class Line():
def init(self,r,angle):
self.r = r
self.angle = angle
def eq(self, other):
if self.r == other.r and self.angle == other.angle:
return True
else:
return False
def hash(self):
result = 31 + int(self.r)
result = 31 * result + int(self.angle * 100)
#print result
return result

class Counter(dict):
def missing(self, key):
return 0

class LineDetectorByHough:
countersDICT = Counter(dict())
def init(self):
pass

def find(self,img):
    rows, cols = img.shape
    print 'rows,cols=', rows, cols
    points = 0
    for x in range(0, rows):
        for y in range(0, cols):
            if (img[x, y] == 1):
                points = points + 1
                for angle in np.arange(0, 2 * np.pi, 2 * np.pi / 40):
                    # print 'angel=',x, y, angel
                    angle = round(angle, 2)
                    angle = angle % round(np.pi, 2)
                    r = round(self.calcR(x, y, angle),1)
                    print 'r,angel=', r, angle
                    self.countersDICT[Line(r, angle)] += 1
    print "points=", points
    print "line (r ,angle) count"

    for (k, v) in self.countersDICT.items():
        if(v > 2):
            print "line ", k.r, k.angle, str(v)  # %(2 * np.pi)
def calcR(self,x,y,angle):
    return x* math.cos(angle) + y * math.sin(angle)
def mask(self,img,x0,y0,template):
    val = 0
    for x in range(-1, 1):
        for y in range(-1, 1):
            val = val +  template[x+1][y+1] * img[x0+x][y0+y]
    return val / 9

from mahotas.

jasson2001 avatar jasson2001 commented on May 31, 2024

This is test code:

-- coding: utf-8 --

import unittest
import math
import numpy as np
import mahotas as mh

import matplotlib
matplotlib.use('TkAgg')

import matplotlib.pyplot as plt
from skimage import data,transform

import pylab

from LineDetectorByHough import LineDetectorByHough
from LineDetectorByHough import Line

class TestLineDetectorByHough(unittest.TestCase):
def test_simpleImg_hough_detect(self):
img = np.zeros((80, 80), bool)
img[6,:] = 1

    pylab.imshow(img)
    pylab.show()
    c = LineDetectorByHough()
    c.find(img)

from mahotas.

luispedro avatar luispedro commented on May 31, 2024

Thanks, I would be happy to help you, but this is very hard to evaluate like this as the formatting is all messed up.

Can you please submit this as a pull request?

from mahotas.

jasson2001 avatar jasson2001 commented on May 31, 2024

Thank you again,
I have submit my code with unit test, and create a pull request,
but CI report error :
/usr/include/features.h:162:0: note: this is the location of the previous definition

define _XOPEN_SOURCE 700

^
In file included from mahotas/numpypp/array.hpp:17:0,
from mahotas/_histogram.cpp:10:
mahotas/numpypp/numpy.hpp:11:33: fatal error: numpy/ndarrayobject.h: No such file or directory
#include <numpy/ndarrayobject.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
make: *** [debug] Error 1
The command ".travis/travis_install.sh" failed and exited with 2 during .

from mahotas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.