Date/Timestamp from...
 
Notifications
Clear all

Date/Timestamp from JPG Images

16 Posts
9 Users
0 Reactions
3,261 Views
jhup
 jhup
(@jhup)
Noble Member
Joined: 16 years ago
Posts: 1442
 

IrfanView maybe of help.

It has a very detailed batch process built into it.

It allows cropping by X/Y pos & height/width, or by start corner, resizing, aspect ratio adjustment, resempling, color debth changing, various sharping, brightness, contrast, gamma correction, etc. and the best sequential renaming with variables.

I would run the batch to crop the images just to the text (since you said they are always in the same spot), reduce the colors to either 4BPP, or if possible just 1BPP.

This would give you just the text, and possibly sufficient contrast that you could feed it to an OCR system.


   
ReplyQuote
(@mscotgrove)
Prominent Member
Joined: 17 years ago
Posts: 940
 

Going one stage further than jhup's idea, it would not be rocket science to write a simple program to convert the JPEG images to bitmaps. Microsoft CImage function will do this work. (PM me if you want any examples).

As the date will just be numbers in fixed locations, then it only takes a simple routine to recognise the symbols 0 - 9 with a fixed colour, size, location etc. It may be possible by just testing about 10 points or pixels for each character.

It may be a very useful project for the many students who are asking for project ideas.


   
ReplyQuote
(@arbert)
Active Member
Joined: 18 years ago
Posts: 14
Topic starter  

Going one stage further than jhup's idea, it would not be rocket science to write a simple program to convert the JPEG images to bitmaps. Microsoft CImage function will do this work. (PM me if you want any examples).

As the date will just be numbers in fixed locations, then it only takes a simple routine to recognise the symbols 0 - 9 with a fixed colour, size, location etc. It may be possible by just testing about 10 points or pixels for each character.

It may be a very useful project for the many students who are asking for project ideas.

I was kind of going down this route. Probably a little more complicated than what your suggesting–Aforge.NET library and attempting a pattern match (coding something now any way to try). You are correct, doesn't really need to be that sophisticated, I just need to recognize everything that has 25 for the day and ignore everything else.


   
ReplyQuote
joakims
(@joakims)
Estimable Member
Joined: 15 years ago
Posts: 224
 

I am trying out MS Office's OCR engine through scripting and using COM; http//msdn.microsoft.com/en-us/library/aa202819(office.11).aspx There's actually many parameters to help identify through, like Text, LineId, RegionId, FontId, FontFontSize and RecognitionConfidence.

But that requires the method of being able to identify/extract text from the image of course. Maybe some preprocessing of the images is necessary..

I think it would be interesting to see some sample scripts on this subject.


   
ReplyQuote
(@mscotgrove)
Prominent Member
Joined: 17 years ago
Posts: 940
 

CImage myImage;
hr = myImage.Load(temp_name);
hr = myImage.Save(temp_name, GdiplusImageFormatBMP);

This load an JPEG and save a BMP. This from a C++ VS2010 program

You then need to loaction in the bitmap (stored upside down!) the location and colur of the numbers. I am guessing that the colur will always be fixed, and so an exact match will always be found. The only area that may cause problems would be due to jpeg lossey compression errors, so you may need some tolerance in mafching


   
ReplyQuote
joakims
(@joakims)
Estimable Member
Joined: 15 years ago
Posts: 224
 

The OCR stuff (at least the way I do it) is really a time hog, so preprocessing the image may increase performance drastically. With cropped images, the OCR routine's time is reduced by at least 50 %. In comparison the time it takes to reformat, redraw and crop the image is under 20% of the time saved through OCR, so you will have a nice net gain in regards to time. However, for some weird reason, the OCR results are affected by an image being cropped, even though the text inside it is the same.

Samples of pattern recognition code would be even more interesting to see..


   
ReplyQuote
Page 2 / 2
Share: