I want to compare images and group similar images and display the images.
Give me an idea how to go about...
sample code will be more helpful
thanks in advance,
Add three picture box's to your form, enable the AutoRedraw property of eachQuote:> I want to compare images and group similar images and display the images.
> Give me an idea how to go about...
> sample code will be more helpful
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, _
ByVal ySrc As Long, ByVal dwRop As Long) As Long
Picture3.BackColor = vbBlack
Call BitBlt(Picture3.hDC(), 0, 0, Picture1.ScaleWidth, _
Picture1.ScaleHeight, Picture1.hDC, 0, 0, vbSrcInvert)
Call BitBlt(Picture3.hDC(), 0, 0, Picture2.ScaleWidth, _
Picture2.ScaleHeight, Picture2.hDC, 0, 0, vbSrcInvert)
An all-black resulting image means you've got the same picture, anything
else means _something_ is different. If you need to know what is different,
then this will create a mask for you:
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, _
ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function SetPixelV Lib "gdi32" (ByVal hDC As Long, _
ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Dim LoopX As Long, LoopY As Long
For LoopX = 0 To Picture3.ScaleWidth - 1
For LoopY = 0 To Picture3.ScaleHeight - 1
Call SetPixelV(Picture3.hDC, LoopX, LoopY, _
IIf(GetPixel(Picture3.hDC, LoopX, LoopY) = _
vbBlack, vbBlack, vbWhite))
You can also use it to find what percentage of the image is different by
unwrapping the IIf(), or just give you a boolean IsSameImage result
depending on what you actually need, your post was rather vague in this
respect so I'm just guessing what you needed..
Hope this helps,
- Microsoft Visual Basic MVP -
> sample code will be more helpful
'***Into a form (contains Picture1 and Picture2)
'***Load Pictures into Picture1 and Picture2.
Private Declare Function GetDIBits& Lib "gdi32" (ByVal hdc&, ByVal hBM&, _
ByVal nStart&, ByVal nNum&, lpBits As Any, lpBI As Any, ByVal Usg&)
Private Sub Form_Click()
MsgBox PicCompare(Picture1, Picture2)
Function PicCompare(P1 As PictureBox, P2 As PictureBox) As Boolean
Dim B1&(), Arr1&(), B2&(), Arr2&(), W1&, W2&, H1&, H2&, x&, y&
GetArrFromHdl Arr1, P1.hdc, P1.Picture, B1, 32
W1 = B1(1): H1 = B1(2)
GetArrFromHdl Arr2, P2.hdc, P2.Picture, B2, 32
W2 = B2(1): H2 = B2(2)
If W1 <> W2 Or H1 <> H2 Then Exit Function
For y = 0 To H1 - 1
For x = 0 To W1 - 1
If Arr1(x, y) <> Arr2(x, y) Then Exit Function
PicCompare = True
Private Sub GetArrFromHdl(P&(), SrcDC&, ByVal Hdl&, BI&(), ByVal BpP&)
Dim W&, H&
ReDim P(0, 0): ReDim BI(1033): BI(0) = 40
GetDIBits SrcDC, Hdl, 0, 0, ByVal 0&, BI(0), 0
W = BI(1): H = BI(2): BI(2) = H: BI(3) = BpP * 65536 + 1: BI(4) = 0
If W = 0 Or H = 0 Then Exit Sub
ReDim P(W * BpP \ 32 - IIf(W * BpP Mod 32, 0, 1), H - 1)
GetDIBits SrcDC, Hdl, 0, H, P(0, 0), BI(0), 0
what i imagine is a software library with a function you can call on 2
images which returns a value describing how equal they are (ie. 100% if
they are equal, and something like a couple random % if they have
nothing in common, and a relatively high % number if they show the same
image, but are different in size or there are some random errors).
does anybody know of a free, preferrably portable, preferrably C or C++
library which can accomplish this?
Sent via Deja.com http://www.deja.com/
Before you buy.
8. fli animator
11. Image Comparison