Does anyone know of a simple implementation of a straight line
detection algorithm something like hough or anything simpler.So
something like if we have a 2D arary of pixel elements representing a
particular Image. How can we identify lines in this Image.
for example:
ary =
[[1,1,1,1,1],
[1,1,0,0,0],
[1,0,1,0,0],
[1,0,0,1,0],
[1,0,0,0,1]]
So if 'ary' represents pxl of an image which has a horizontal line(row
0),a vertical line(col 0) and a diagonal line(diagonal of ary). then
basically I want identify any horizontal or vertical or diagonal line
anywhere in the pxl array.
Thanks. 3 4345
"PyPK" <su*******@gmai l.com> wrote: Does anyone know of a simple implementation of a straight line detection algorithm something like hough or anything simpler.So something like if we have a 2D arary of pixel elements representing a particular Image. How can we identify lines in this Image. for example:
ary = [[1,1,1,1,1], [1,1,0,0,0], [1,0,1,0,0], [1,0,0,1,0], [1,0,0,0,1]] So if 'ary' represents pxl of an image which has a horizontal line(row 0),a vertical line(col 0) and a diagonal line(diagonal of ary). then basically I want identify any horizontal or vertical or diagonal line anywhere in the pxl array.
If all you want is horizontal, vertical, or 45 degree diagonal, it's pretty
easy to do that just be checking all of the possibilities.
But what if your array is:
[[1,1,1,1,1],
[1,1,1,1,1],
[1,1,1,1,1],
[1,1,1,1,1],
[1,1,1,1,1]]
Would you say there were 12 lines there?
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
PyPK wrote: Does anyone know of a simple implementation of a straight line detection algorithm something like hough or anything simpler.So something like if we have a 2D arary of pixel elements representing a particular Image. How can we identify lines in this Image. for example:
ary = [[1,1,1,1,1], [1,1,0,0,0], [1,0,1,0,0], [1,0,0,1,0], [1,0,0,0,1]] So if 'ary' represents pxl of an image which has a horizontal line(row 0),a vertical line(col 0) and a diagonal line(diagonal of ary). then basically I want identify any horizontal or vertical or diagonal line anywhere in the pxl array.
Thanks.
I would recommend using a module for computing, my choice would be
numarray: http://www.stsci.edu/resources/softw...dware/numarray
You could even write your own version of hough, should not be too complex.
A fwee things you need to consider:
1) Are all the lines through the image, or would a row with
[0,0,1 ...(a few dozen ones in here) ... 1,0] be a line?
2) Do you also need edge detection? Then you might need to convolve
the image with a Laplacian or something like that, e.g.
new[i,j] = (4*old[i,j])-old[i-1,j]-old[i+1,j]-old[i,j-1]-old[i,j+1]
3) How "full" are the images?
It is much easier if only a small fraction of your image is lines,
in your example more than half of image pixels are lines.
4) How big images are you processing? I always have at least
one million pixels, so the rest may not work for small images.
To do some quicklook checks you can of course go through each row/column
and check if the values are different enough, something like
mat = numarray.array( ima)
x = mat.mean()
dx = mat.stddev()
then check if some rows are different from others, maybe
(mat[:,i].mean() > (x + N*dx)) for "white" lines or
(mat[:,i].mean() < (x - N*dx))) for "black" lines
you probably need do a few tests to get a good value of N.
repeat for columns (mat[j,:]) and diagonals:
numarray.diagon al(mat,o) where
o is offset from mat[0,0]
and if you need non-diagonal elements, say
ima = [[1 0 0 0 0]
[0 0 1 0 0]
[0 0 0 0 1]]
would contain a line of ones, then
vect = ima.flat
gives the image as a rank-1 array and you can then take strides
(every nth element) just like with normal lists, array[a:b:n]
takes every nth element in array[a:b], so vect[::7] would be [1 1 1]
I hope this helps a bit.
Tim Roberts wrote: "PyPK" <su*******@gmai l.com> wrote: Does anyone know of a simple implementation of a straight line detection algorithm something like hough or anything simpler.So something like if we have a 2D arary of pixel elements representing a particular Image. How can we identify lines in this Image. for example:
ary = [[1,1,1,1,1], [1,1,0,0,0], [1,0,1,0,0], [1,0,0,1,0], [1,0,0,0,1]] So if 'ary' represents pxl of an image which has a horizontal line(row 0),a vertical line(col 0) and a diagonal line(diagonal of ary). then basically I want identify any horizontal or vertical or diagonal line anywhere in the pxl array.
If all you want is horizontal, vertical, or 45 degree diagonal, it's pretty easy to do that just be checking all of the possibilities.
But what if your array is:
[[1,1,1,1,1], [1,1,1,1,1], [1,1,1,1,1], [1,1,1,1,1], [1,1,1,1,1]]
Would you say there were 12 lines there?
Actually I'd say 24.
5 vertical,
5 horizontal,
7 diagonal downward to the right (lengths 2,3,4,5,4,3,2)
7 diagonal downward to the left (lengths 2,3,4,5,4,3,2)
--
Nigel Rowe
A pox upon the spammers that make me write my address like..
rho (snail) swiftdsl (stop) com (stop) au This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: yawnmoth |
last post by:
say i have a for loop that would iterate through every character and
put a space between every 80th one, in effect forcing word wrap to
occur. this can be implemented easily using a regular expression.
if i wanted to improve on this, and make it so stuff in url's didn't
count towards that 80 character limit, a regular expression would not
suffice. however, a simple for loop does.
so now i'm currious how to account for html escape...
|
by: Fotios |
last post by:
Hi guys,
I have put together a flexible client-side user agent detector (written in
js). I thought that some of you may find it useful. Code is here:
http://fotios.cc/software/ua_detect.htm
The detector requires javascript 1.0 to work. This translates to netscape
2.0 and IE 3.0 (although maybe IE 2.0 also works with it)
|
by: R. Smits |
last post by:
I've have got this script, the only thing I want to be changed is the first
part. It has to detect IE version 6 instead of just "Microsoft Internet
Explorer". Can somebody help me out?
I tried "Microsoft Internet Explorer 6" but that doesn't work.
<SCRIPT LANGUAGE="Javascript">
<!--
bName = navigator.appName;
if (bName =="Microsoft Internet Explorer") {
document.write('<link media="screen" rel="STYLESHEET" type="text/css"
|
by: mosaic |
last post by:
Hi, all
I really interested in how to check the memory leak of a program.
Your smart guys, do you have excellent ideas that could share with me?
Thank you.
The following is my idea:
In C programming language, there's a "malloc", there must a "free",
my solution of the detection of leak is, find the corresponding "free"
of "malloc". This the first condition.
|
by: Michael Rodriguez |
last post by:
In Delphi there was a control called a Bevel. It would let you draw
straight lines, top, left, right, or bottom, anywhere on your screen.
What is the equivalent in C#? How can I draw a straight line across the
screen?
TIA,
Mike Rodriguez
| |
by: darrenhello |
last post by:
hi there,
I am doing my last year's project and I have a 'little' problem. I have to do an edge detection filter. for now, some normal edge detection filters that I used worked fine but there a problem. I need an edge detection filter in which I can offset the edge according to a variable that the user gives. The problem is that I got no idea of how to make an edge detection filter with an offset.
anyone can help please?
thank you
|
by: origami.takarana |
last post by:
Intrusion Detection Strategies
-----------------------------------
Until now, we’ve primarily discussed monitoring in how it relates to
intrusion detection, but there’s more to an overall intrusion
detection installation than monitoring alone. Monitoring can help you
spot problems in your network, as well as identify performance
problems, but watching every second of traffic that passes through
your network, manually searching for...
|
by: Thekid |
last post by:
Hi, I'm not very good with javascript but I wanted to know if there was a simple way to change this code so instead of printing out the numbers & letters in a spiral on the page, it can be changed to print them out in a straight line or straight lines? Or if there's a simple rewrite for it....
p.s. this needs Firefox
<html>
<head>
<script type="text/javascript">
<!--
//----------------------------------------------------------------...
|
by: Conrad Lender |
last post by:
In a recent thread in this group, I said that in some cases object
detection and feature tests weren't sufficient in the development of
cross-browser applications, and that there were situations where you
could improve the application by detecting the browser vendor/version.
Some of the posters here disagreed. Since then, I've had to deal with a
few of these cases; some of them could be rewritten to use object
detection, and some couldn't....
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |