Dear Programmers I need your help,
I have a PictureBox there I load A picture retrieved from Database.
This so far good, but Now I want to scan the picture line by line horizontaly, to find which line of the picture that contains most pixels. How can I do that ?
Many Thanx
3 2501
Hi Killer.
I use VB6.0 for this project.
I read a picture in a picturebox. The picture is a Signature.
I have 10 lines and I need to locate them there (on the Signature-Picture) which have the most pixels with a horizontaly direction. For that I scan the height of the picture, line by line. (I hope I am giving a clear view of what I am doing so far!)
'---------------------------------------------
Here I send U my codes. Each line I scan I get the black pixels which are continuously laid after each other(The signature is black on a white paper).
Each time I find the segment I count the black pixels and then save it to an array, the next segment of the same line if bigger than the previous value is replaced.
'------------------------------------------------------------------------------------------------------------------
'I scan the height of the picture horizontaly and find the biggest value of black-pxls that are continuously laid,
'after each other on a line, the first 10 line and store them in arrLines().
'For the lines with height >=10, if their biggest value is bigger than the smallest value in the array, I replace.
'------------------------------------------------------------------------------------------------------------------ - Dim X As Long, lW As Long, Y As Long, lH As Long, lPxl As Long
-
Dim arrLines(0 To 9) As Long, arrHeight(0 To 9) As Long, arrTemp(0) As Long
-
Dim nNumPxl As Integer, nCompare As Integer
-
Dim nVal1 As Integer, nVal2 As Integer, nSmall As Integer, nIdx As Integer, i As Integer
-
Dim nResult As Integer, nIdxResult As Integer
-
-
lW = lPicWPxl
-
lH = lPicHPxl
-
nResult = 10000
-
For Y = 0 To lH
-
For X = 0 To lW
-
lPxl = GetPixel(Pic_Overview.hdc, X, Y)
-
If lPxl = 0 Then
-
nNumPxl = nNumPxl + 1
-
' MsgBox nNumPxl
-
Else
-
If nNumPxl > 0 Then
-
If Y < 10 Then 'The first 10 lines.
-
nCompare = arrLines(Y)
-
If nNumPxl > nCompare Then
-
arrLines(Y) = nNumPxl
-
End If
-
nNumPxl = 0
-
Else 'From Y>=10 compare the value with the smallest value in arrLines(), if the value bigger than the smallest replace it!
-
nCompare = arrTemp(0)
-
If nNumPxl > nCompare Then
-
arrTemp(0) = nNumPxl
-
End If
-
nNumPxl = 0
-
End If
-
End If
-
End If
-
Next X
-
If Y < 10 Then
-
arrHeight(Y) = Y
-
Else
-
For nIdx = LBound(arrLines) To (UBound(arrLines) - 1)
-
nVal1 = arrLines(nIdx)
-
nVal2 = arrLines(nIdx + 1)
-
If nVal2 < nVal1 Then
-
nSmall = nVal2
-
i = nIdx + 1
-
Else
-
nSmall = nVal1
-
i = nIdx
-
End If
-
If nSmall < nResult Then
-
nResult = nSmall
-
nIdxResult = i
-
End If
-
Next nIdx
-
If arrTemp(0) > nResult Then
-
arrLines(nIdxResult) = arrTemp(0)
-
arrHeight(nIdxResult) = Y
-
End If
-
nResult = 10000
-
arrTemp(0) = 0
-
End If
-
' nNumPxl = 0
-
Next Y
-
'---------------------Set 10 lines!
-
Line_GetPxl1.Y1 = arrHeight(0)
-
Line_GetPxl1.Y2 = Line_GetPxl1.Y1
-
Line_GetPxl1.Visible = True
-
Line_GetPxl2.Y1 = arrHeight(1)
-
Line_GetPxl2.Y2 = Line_GetPxl2.Y1
-
Line_GetPxl2.Visible = True
-
'
-
'
-
'-----------------------------------etc
This solution is not accepted (by boss). According to him I need to find the direction of each pixel!
I have seen on Internet its about MATLAB and very complicated math-calculation and transformation and so on....
I am lost and I need help.
Do U have any idea for my problem ?
Thank U on forhand.
/Anoosha
What version of VB?
A pixel doesn't have a direction, just a colour.
Anyway, I'll go through this at lunch time and see whether I can think of anything that might help (don't have time right now).
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: jeff |
last post by:
Hiya,
Im currently in the process of developing a picture browser, I want it
to run off a CD, basically I have 2 questions for the group.
The first is how do I get the program to only view the contents of the
CD, at the moment i have a drop down drive menu that allows me to
select the drive, i want to be able to put the CD in and then have i
view only the CD contents, Ive considered just entering in my code D:\
but what happens if the...
|
by: Chris |
last post by:
Hi,
I am trying to set the position of a picture inside a picturebox with the
folowing code:
pctOutput.Picture = LoadPicture(App.Path & "\picture.bmp", ,
, , )
I didn't know what to fill in at and so the result was:
|
by: Chris Coho, Jr. |
last post by:
Ok, I'll explain the whole problem because there may be several ways to
solve this and hopefully someone knows one. What I'm doing is creating
a specialty template editor, similar to say a corel draw (but for
specific uses). What I need to be able to do is import graphics and
text and then move them around the background until they are where I
want them and then export it out as an image file.
The problem is that I need to be able to...
|
by: Sandra Setz |
last post by:
Hi,
Is it possible to assign the Picture property of a picturebox to the
Picture property of an image control?
I use an invisble picturebox to make some changes to a picture, but I
want to show the picture in an imagecontrol, since the image is very
large and I want to stretch it.
But when I execute the following code:
|
by: Dennis |
last post by:
Hello,
Ive to draw a line on a picture i used this code:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
x1 = z.X
y1 = z.Y
lbl3 = "x1: " & x1
lbl4 = "y1: " & y1
| |
by: Bill N. |
last post by:
Using VB .Net 2003 Standard Edition.
This simple form has a "File in Use" problem while the executable is running.
Created this simple program to make sure that I hadn't done something in my
code in the "real" project.
In the "real" project, One part of the program saves multiple images and
another part of the program moves the images to the appropriate directories
based on user feedback.
|
by: Michael Lehar |
last post by:
Hallo
I have a pictureBox with a picture loaded from file, then I draw some
lines on the picture, and then I want to save the new picture.
Befor I can draw lines I have to create a Graphics object, with g =
pictureBox.CreateGraphic, and draw lines g.drawLines(....)
But when saving the picture, the new picture have no lines, it is only
a copy.
|
by: Jeff Williams |
last post by:
I have several picture boxes on a form. I want to be able to drag
pictures to this picture box. On the Drop how can I tell which picture
box I am dropping the picture on. Te picture Box control name or
control text would suit my needs.
Regards
Jeff
|
by: debasisdas |
last post by:
Add two picture boxes to a form.
Set the ScaleMode property of both the pictureboxes to 3-Pixels.
General declaration
--------------------------------
Const ubx = 1000
Const uby = 500
Dim pixels(1 To ubx, 1 To uby) As Long
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |