假設,
今天有一張圖片a與一張圖片b
圖片b是由圖片a的某一個區塊所截取下來的!
那麼,我想透過一個程式去判斷b是在a的那一個區域裡?
不曉得這樣的程式該由何種語言去撰寫?
有那些語言可以去處理圖片的?
不好意思,小弟所學不多,實在想不到圖片的處理該使用何種語言…
但是最近偏偏對這方面有些興趣,
想找本書好下手...
麻煩各位大大為我解答一下好嗎?^^
((有好書可以推的更是感激不盡…))
http://sourceforge.net/
http://freshmeat.net/
http://www.codeguru.com/
http://www.codeproject.com/
拿keyword去搜尋一下
有多到爆炸的sample code讓你看不完
我貼的是VB.NET版的。
我大略講解一下:
1.先把圖片載入
2.把圖片轉換成一維陣列
3.把陣列Copy到memory
4.再memory中處理陣列,此範例是把RGB其中一種顏色顯示出來(1張圖片是由RGB這3色組成的)
5.處理完後把陣列從記憶體中丟出來
你需要做的事就是在第4步驟上動手腳,就是你想要做的圖片比較。
P.S 為何要丟到記憶體處理完再丟出來呢?因為速度會加速非常的快。
如果你直接處理的話,圖一大就會很慢很慢(取決於你的CPU)
--------------------------------------------------------------
Private Sub LockUnlockBitsExample(ByVal e As PaintEventArgs)
' Create a new bitmap.
Dim bmp As New Bitmap("c:\fakePhoto.jpg")
' Lock the bitmap's bits.
Dim rect As New Rectangle(0, 0, bmp.Width, bmp.Height)
Dim bmpData As System.Drawing.Imaging.BitmapData = bmp.LockBits(rect, _
Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat)
' Get the address of the first line.
Dim ptr As IntPtr = bmpData.Scan0
' Declare an array to hold the bytes of the bitmap.
' This code is specific to a bitmap with 24 bits per pixels.
Dim bytes As Integer = bmp.Width * bmp.Height * 3
Dim rgbValues(bytes - 1) As Byte
' Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes)
' Set every red value to 255.
For counter As Integer = 0 To rgbValues.Length - 1 Step 3
rgbValues(counter) = 255
Next
' Copy the RGB values back to the bitmap
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes)
' Unlock the bits.
bmp.UnlockBits(bmpData)
' Draw the modified image.
e.Graphics.DrawImage(bmp, 0, 150)
End Sub
內文搜尋

X