Sergey89 писал(а):Нужна помощь в реализации подсчета яркости интегрального изображения под признаком в светлых и темных областях.
Qwertiy писал(а):Debugger, а под какой вопрос ты предлагаешь решение?
Debugger писал(а):Если надо быстро
Public Sub FF(Ar(), nm)
Dim rex(1050) As Double
Dim Imx(1056) As Double
Dim a(1050) As Double
Dim n As Integer
Dim i As Integer
Dim j As Double
Dim C(1050) As Double
Const Pi = 3.1415926
n = nm
'For j = 0 To N / 2
mm:
rex(j) = 0
Imx(j) = 0
For i = 1 To n Step 1
j = j + 1 / n
rex(j) = rex(j) + Ar(i) * Cos(2 * Pi * i * (j / n))
Imx(j) = Imx(j) - Ar(i) * Sin(2 * Pi * i * (j / n))
DoEvents
a(j) = Sqr(Imx(j) ^ 2 + rex(j) ^ 2)
P3.Line (i, a(j))-(i, a(j-1)), vbBlack
Next
If j < n / 2 Then GoTo mm
End Sub
Private Sub Command1_Click()
Dim Pi As Double
Pi = 3.14159265
loaddata
Dim N As Integer
N = C
ReDim REX(C / 2)
ReDim IMX(C / 2)
ReDim Frekans(C / 2)
For K = 1 To N / 2
For i = 1 To N - 1
REX(K) = REX(K) + XX(i) * Cos(2 * Pi * K * i / N) 'reel
IMX(K) = IMX(K) - XX(i) * Sin(2 * Pi * K * i / N) 'Imaginary
Next i
Frekans(K) = Sqr(REX(K) ^ 2 + IMX(K) ^ 2) '
Next K
For K = 1 To N / 2
'Text1.Text = Text1.Text & Frekans(K) & vbCrLf
Picture2.PSet (K, Picture2.ScaleHeight - Frekans(K) / Picture2.ScaleHeight), vbRed
Picture2.Line (K, Picture2.ScaleHeight - Frekans(K) / Picture2.ScaleHeight)-(K, Picture2.ScaleHeight - Frekans(K - 1) / Picture2.ScaleHeight), vbRed
Next K
Close
End Sub
Option Explicit
Dim XX() As Double
Dim REX() As Double
Dim IMX() As Double
Dim K As Double
Dim i As Integer
Dim C As Integer
Dim Frekans() As Double
Dim b() As Double
Dim Value() As Currency
Private Sub Command1_Click()
Dim t1, t2
Dim Pi As Double
Dim N As Integer
t1 = Time
loaddata
Pi = 3.14159265
N = C
ReDim REX(C / 2)
ReDim IMX(C / 2)
ReDim Frekans(C / 2)
For K = 1 To N / 2
For i = 1 To N - 1
REX(K) = REX(K) + XX(i) * Cos(2 * Pi * K * i / N) 'reel
IMX(K) = IMX(K) - XX(i) * Sin(2 * Pi * K * i / N) 'Imaginary
Next i
Frekans(K) = Sqr(REX(K) ^ 2 + IMX(K) ^ 2) '
Next K
For K = 1 To N / 2
Picture2.PSet (K, Picture2.ScaleHeight - (Frekans(K) / Picture2.ScaleHeight)), vbRed
Picture2.Line (K, Picture2.ScaleHeight - (Frekans(K) / Picture2.ScaleHeight))-(K, Picture2.ScaleHeight - (Frekans(K - 1) / Picture2.ScaleHeight)), vbRed
Next K
t2 = Time
Caption = Abs(DateDiff("s", t1, t2))
Close
End Sub
Sub loaddata()
Dim z As Integer, w As Integer, h As Integer
Dim y As Integer
w = Picture1.ScaleWidth
h = Picture1.ScaleHeight
C = w * h
ReDim Preserve XX(C)
For z = 0 To C
y = Int(z / w)
XX(z) = Picture1.Point(z - (y * w), (z - (z - (y * w) / w))) Mod 256
If XX(z) <= 0 Then XX(z) = 1
If XX(z) > 255 Then XX(z) = 255
Next z
Close
End Sub
Function FFT2(a() As Double, nn As Integer, InverseFFT As Boolean)
Dim Jj As Integer, N As Integer, Mmax As Integer, m As Integer, j As Integer, istep As Integer, I As Integer, isign As Integer
Dim wtemp As Double, wr As Double, wpr As Double, wpi As Double, wi As Double, theta As Double, tempr As Double, tempi As Double
List2.Clear
If InverseFFT Then
isign = -1
Else
isign = 1
End If
N = 2 * nn
j = 1
ii = 1
Do While ii <= nn
I = 2 * ii - 1
If j > I Then
tempr = a(j - 1)
tempi = a(j)
a(j - 1) = a(I - 1)
a(j) = a(I)
a(I - 1) = tempr
a(I) = tempi
End If
m = N \ 2
Do While (m >= 2) And (j > m)
j = j - m
m = m \ 2
Loop
j = j + m
ii = ii + 1
Loop
Mmax = 2
Do While N > Mmax
istep = 2 * Mmax
theta = 2 * PI / (isign * Mmax)
wpr = -2# * Sin(0.5 * theta)
wpi = Sin(theta)
wr = 1#
wi = 0#
ii = 1
Do While ii <= Mmax \ 2
m = 2 * ii - 1
Jj = 0
Do While Jj <= (N - m) \ istep
I = m + Jj * istep
j = I + Mmax
tempr = wr * a(j - 1) - wi * a(j)
tempi = wr * a(j) + wi * a(j - 1)
a(j - 1) = a(I - 1) - tempr
a(j) = a(I) - tempi
a(I - 1) = a(I - 1) + tempr
a(I) = a(I) + tempi
Jj = Jj + 1
Loop
wtemp = wr
wr = wr * wpr - wi * wpi + wr
wi = wi * wpr + wtemp * wpi + wi
ii = ii + 1
Loop
Mmax = istep
Loop
If InverseFFT Then
For I = 1 To nn - 1
a(I - 1) = a(I - 1) / nn
Next I
End If
Picture2.Cls
Dim Am() As Double
ReDim Am(N) As Double
For I = 1 To N - 1
'List2.AddItem a(I) / nn
Am(I) = Sqr(a(I) * a(I) + a(I + 1) * a(I + 1)) / nn
Picture2.Line (I, Picture2.ScaleHeight - Am(I))-(I, Picture2.ScaleHeight - Am(I - 1)), vbRed
Next I
End Function
Сейчас этот форум просматривают: Google-бот и гости: 31