Compare two scanned images!
-
as i previously posted http://www.codeproject.com/Forums/1646/Visual-Basic.aspx?fid=1646&fr=51#xx0xx[^] i still didnt find solution to make it work! :( i made my application to scan picture find the business card on whole 1275x1775 and auto crop it so i get just 300x250 business card scaned! and it works good :P but now i need to compre two scaned images of those business cards and tell difference if exsample one is missing one corner or have hole in the middle... i made it work with pixelbypixel search but its to slow and gives me bad results! the only thing i found working just the way i want it to work is the vistor's compare in this project http://rapidshare.com/files/389129825/compar.zip.html[^] from this site http://catenarysystems.com/howto/comparator.html[^] :( can annyone help? i would really want to finish that application until monday i just missing that compare thing :( thank you :thumbsup:
FeRtoll Software.net ------------ E-Mail me WebPage
-
as i previously posted http://www.codeproject.com/Forums/1646/Visual-Basic.aspx?fid=1646&fr=51#xx0xx[^] i still didnt find solution to make it work! :( i made my application to scan picture find the business card on whole 1275x1775 and auto crop it so i get just 300x250 business card scaned! and it works good :P but now i need to compre two scaned images of those business cards and tell difference if exsample one is missing one corner or have hole in the middle... i made it work with pixelbypixel search but its to slow and gives me bad results! the only thing i found working just the way i want it to work is the vistor's compare in this project http://rapidshare.com/files/389129825/compar.zip.html[^] from this site http://catenarysystems.com/howto/comparator.html[^] :( can annyone help? i would really want to finish that application until monday i just missing that compare thing :( thank you :thumbsup:
FeRtoll Software.net ------------ E-Mail me WebPage
You have to account for the fact that no two scans of the exact same card will result in a pixel-by-pixel equality. Every pixel is going to be a slightly different color than the same pixel in the previous scan. If all you're doing is OCR'ing the business cards, why even bother comparing two images of the cards and just compare the data that's coming off them? If you have to compare the images, then you'll have to implement a filter (in C#, not VB.NET!) to process the image to equalize the colors. For example, if you look at the white part of a business card, you'll see a scattering of pixels of different colors, not an even white acrossed all of them. You have to implement a filter to remove all those color variations to generate the nice flat color acrossed all pixels. Search the articles for "image processing for dummies" and you'll find some good examples by Christian Graus. Ph, you can't do this in VB.NET. If you wanted any speed at all, it has to be done in C#, or some other managed language that supports pointers. VB.NET doesn't.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
You have to account for the fact that no two scans of the exact same card will result in a pixel-by-pixel equality. Every pixel is going to be a slightly different color than the same pixel in the previous scan. If all you're doing is OCR'ing the business cards, why even bother comparing two images of the cards and just compare the data that's coming off them? If you have to compare the images, then you'll have to implement a filter (in C#, not VB.NET!) to process the image to equalize the colors. For example, if you look at the white part of a business card, you'll see a scattering of pixels of different colors, not an even white acrossed all of them. You have to implement a filter to remove all those color variations to generate the nice flat color acrossed all pixels. Search the articles for "image processing for dummies" and you'll find some good examples by Christian Graus. Ph, you can't do this in VB.NET. If you wanted any speed at all, it has to be done in C#, or some other managed language that supports pointers. VB.NET doesn't.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
You have to account for the fact that no two scans of the exact same card will result in a pixel-by-pixel equality. Every pixel is going to be a slightly different color than the same pixel in the previous scan. If all you're doing is OCR'ing the business cards, why even bother comparing two images of the cards and just compare the data that's coming off them? If you have to compare the images, then you'll have to implement a filter (in C#, not VB.NET!) to process the image to equalize the colors. For example, if you look at the white part of a business card, you'll see a scattering of pixels of different colors, not an even white acrossed all of them. You have to implement a filter to remove all those color variations to generate the nice flat color acrossed all pixels. Search the articles for "image processing for dummies" and you'll find some good examples by Christian Graus. Ph, you can't do this in VB.NET. If you wanted any speed at all, it has to be done in C#, or some other managed language that supports pointers. VB.NET doesn't.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...Dave Kreskowiak wrote:
You have to account for the fact that no two scans of the exact same card will result in a pixel-by-pixel equality. Every pixel is going to be a slightly different color than the same pixel in the previous scan.
i know that and understand what you mean so i made:
Private Function CheckPixel(ByVal source_color As Color, ByVal search_color As Color, ByVal tolerancy As Integer) As Boolean
Dim sense As Long
sense = 255 - tolerancy * 5CheckPixel = (System.Math.Sqrt((Val(source\_color.R.ToString) - Val(search\_color.R.ToString)) \* (Val(source\_color.R.ToString) - Val(search\_color.R.ToString)) + (Val(source\_color.G.ToString) - Val(search\_color.G.ToString)) \* (Val(source\_color.G.ToString) - Val(search\_color.G.ToString)) + (Val(source\_color.B.ToString) - Val(search\_color.B.ToString)) \* (Val(source\_color.B.ToString) - Val(search\_color.B.ToString))) > sense) End Function
wich is working ok for pixelbypixel search! but i dont want pixelbypixel search or do want i dont know thats why i posted a link to rapidshare file and application with source wich contains my needs!
Dave Kreskowiak wrote:
If all you're doing is OCR'ing the business cards, why even bother comparing two images of the cards and just compare the data that's coming off them?
no i am not doing ocr. i have button "start" and then i scan image and compare to an image that is stored to database and detect difference on those two images and pixelbypixel is slow and not good result but with the code for detect difference from link i posted would do what i want! Here are images you can try with the application i posted and see what i want! ORIGINAL : http://img96.imageshack.us/img96/3540/originalsp.jpg[^] SCANED : http://img717.imageshack.us/img717/3461/damaged.jpg[^] COMPARED : http://img32.imageshack.us/img32/5895/comparator.jpg[^]
-
Dave Kreskowiak wrote:
You have to account for the fact that no two scans of the exact same card will result in a pixel-by-pixel equality. Every pixel is going to be a slightly different color than the same pixel in the previous scan.
i know that and understand what you mean so i made:
Private Function CheckPixel(ByVal source_color As Color, ByVal search_color As Color, ByVal tolerancy As Integer) As Boolean
Dim sense As Long
sense = 255 - tolerancy * 5CheckPixel = (System.Math.Sqrt((Val(source\_color.R.ToString) - Val(search\_color.R.ToString)) \* (Val(source\_color.R.ToString) - Val(search\_color.R.ToString)) + (Val(source\_color.G.ToString) - Val(search\_color.G.ToString)) \* (Val(source\_color.G.ToString) - Val(search\_color.G.ToString)) + (Val(source\_color.B.ToString) - Val(search\_color.B.ToString)) \* (Val(source\_color.B.ToString) - Val(search\_color.B.ToString))) > sense) End Function
wich is working ok for pixelbypixel search! but i dont want pixelbypixel search or do want i dont know thats why i posted a link to rapidshare file and application with source wich contains my needs!
Dave Kreskowiak wrote:
If all you're doing is OCR'ing the business cards, why even bother comparing two images of the cards and just compare the data that's coming off them?
no i am not doing ocr. i have button "start" and then i scan image and compare to an image that is stored to database and detect difference on those two images and pixelbypixel is slow and not good result but with the code for detect difference from link i posted would do what i want! Here are images you can try with the application i posted and see what i want! ORIGINAL : http://img96.imageshack.us/img96/3540/originalsp.jpg[^] SCANED : http://img717.imageshack.us/img717/3461/damaged.jpg[^] COMPARED : http://img32.imageshack.us/img32/5895/comparator.jpg[^]
Pf course your search is slow! First, you're using GetPixel, which takes an eternity to execute. Second, this code is garbage:
CheckPixel = (System.Math.Sqrt((Val(source_color.R.ToString) - Val(search_color.R.ToString)) * (Val(source_color.R.ToString) - Val(search_color.R.ToString)) + (Val(source_color.G.ToString) - Val(search_color.G.ToString)) * (Val(source_color.G.ToString) - Val(search_color.G.ToString)) + (Val(source_color.B.ToString) - Val(search_color.B.ToString)) * (Val(source_color.B.ToString) - Val(search_color.B.ToString))) > sense)
Your converting each RGB value component, say R, to a string, then back to a value. This is VERY time consuming an completely unnecessary. Not only are you doing it at all, you're doing it several times for each time you use the same value! The only way you're going to improve performance is to scrap this code and rewrite it in C# and directly access the image data. You cannot do this in VB.NET because it requires the use of unsafe pointers, which VB.NET does not support. Search the articles for "image processing for dummies" and you'll find a very good series of articles by Christian Graus explaining just how this is done.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
Pf course your search is slow! First, you're using GetPixel, which takes an eternity to execute. Second, this code is garbage:
CheckPixel = (System.Math.Sqrt((Val(source_color.R.ToString) - Val(search_color.R.ToString)) * (Val(source_color.R.ToString) - Val(search_color.R.ToString)) + (Val(source_color.G.ToString) - Val(search_color.G.ToString)) * (Val(source_color.G.ToString) - Val(search_color.G.ToString)) + (Val(source_color.B.ToString) - Val(search_color.B.ToString)) * (Val(source_color.B.ToString) - Val(search_color.B.ToString))) > sense)
Your converting each RGB value component, say R, to a string, then back to a value. This is VERY time consuming an completely unnecessary. Not only are you doing it at all, you're doing it several times for each time you use the same value! The only way you're going to improve performance is to scrap this code and rewrite it in C# and directly access the image data. You cannot do this in VB.NET because it requires the use of unsafe pointers, which VB.NET does not support. Search the articles for "image processing for dummies" and you'll find a very good series of articles by Christian Graus explaining just how this is done.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...I concluded from this only one thing, you dont like vb.net annymore and force to the c#! :((
Dave Kreskowiak wrote:
Visual Developer - Visual Basic 2006, 2007, 2008 But no longer in 2009...
:-D code is not optimized, because I have working fast and I wanted it to do it till Monday (tomorrow) finish! :doh: btw. I finished and everything is working nice and pretty fast (but i need to optimize code now, i have much unused codes and garbages to clean like "Val(search_color.R.ToString)")! ;P
Dave Kreskowiak wrote:
Search the articles for "image processing for dummies" and you'll find a very good series of articles by Christian Graus explaining just how this is done.
in c# yes, but i am here asking for vb.net! I would prefer to learn assembler rather than c#, actualy i dont like c# i hate it... just becose of name! ;P and how people say it... ;P i am joking! and here is the thing i wanted... http://www.metacafe.com/watch/4656502/imco/[^] yes it's nothing special but for v1.0 is enough!
FeRtoll Software.net ------------ E-Mail me WebPage
-
I concluded from this only one thing, you dont like vb.net annymore and force to the c#! :((
Dave Kreskowiak wrote:
Visual Developer - Visual Basic 2006, 2007, 2008 But no longer in 2009...
:-D code is not optimized, because I have working fast and I wanted it to do it till Monday (tomorrow) finish! :doh: btw. I finished and everything is working nice and pretty fast (but i need to optimize code now, i have much unused codes and garbages to clean like "Val(search_color.R.ToString)")! ;P
Dave Kreskowiak wrote:
Search the articles for "image processing for dummies" and you'll find a very good series of articles by Christian Graus explaining just how this is done.
in c# yes, but i am here asking for vb.net! I would prefer to learn assembler rather than c#, actualy i dont like c# i hate it... just becose of name! ;P and how people say it... ;P i am joking! and here is the thing i wanted... http://www.metacafe.com/watch/4656502/imco/[^] yes it's nothing special but for v1.0 is enough!
FeRtoll Software.net ------------ E-Mail me WebPage
-
I concluded from this only one thing, you dont like vb.net annymore and force to the c#! :((
Dave Kreskowiak wrote:
Visual Developer - Visual Basic 2006, 2007, 2008 But no longer in 2009...
:-D code is not optimized, because I have working fast and I wanted it to do it till Monday (tomorrow) finish! :doh: btw. I finished and everything is working nice and pretty fast (but i need to optimize code now, i have much unused codes and garbages to clean like "Val(search_color.R.ToString)")! ;P
Dave Kreskowiak wrote:
Search the articles for "image processing for dummies" and you'll find a very good series of articles by Christian Graus explaining just how this is done.
in c# yes, but i am here asking for vb.net! I would prefer to learn assembler rather than c#, actualy i dont like c# i hate it... just becose of name! ;P and how people say it... ;P i am joking! and here is the thing i wanted... http://www.metacafe.com/watch/4656502/imco/[^] yes it's nothing special but for v1.0 is enough!
FeRtoll Software.net ------------ E-Mail me WebPage
FeRtoll wrote:
I concluded from this only one thing, you dont like vb.net annymore and force to the c#!
First, I already told you why you could not do this entirely in VB.NET. Go back and re-read it.
FeRtoll wrote:
Dave Kreskowiak wrote: Visual Developer - Visual Basic 2006, 2007, 2008 But no longer in 2009...
Because I've spent far more time with my son than here. That's all...
FeRtoll wrote:
in c# yes, but i am here asking for vb.net!
There is no equivilent in VB.NET. I already told you VB.NET does not support pointers, making writing it in VB.NET impossible.
FeRtoll wrote:
I would prefer to learn assembler rather than c#,
Waste your time however you want. C# is so very close to VB.NET, so you know more about it than you realize.
FeRtoll wrote:
and how people say it... i am joking!
I'm not...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
FeRtoll wrote:
I concluded from this only one thing, you dont like vb.net annymore and force to the c#!
First, I already told you why you could not do this entirely in VB.NET. Go back and re-read it.
FeRtoll wrote:
Dave Kreskowiak wrote: Visual Developer - Visual Basic 2006, 2007, 2008 But no longer in 2009...
Because I've spent far more time with my son than here. That's all...
FeRtoll wrote:
in c# yes, but i am here asking for vb.net!
There is no equivilent in VB.NET. I already told you VB.NET does not support pointers, making writing it in VB.NET impossible.
FeRtoll wrote:
I would prefer to learn assembler rather than c#,
Waste your time however you want. C# is so very close to VB.NET, so you know more about it than you realize.
FeRtoll wrote:
and how people say it... i am joking!
I'm not...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...