Inlab Networks : Software : Inlab-Scheme : Example
BalanceNG
RBridge
Balance
Inlab-Scheme
Features
Example
Download
 
BalanceNG - The Software Load Balancer
BalanceNG®

The Software Load Balancer and Embeddable ADC

BalanceNG certified system
Thomas-Krenn LoadBalancer
certified OEM Load-Balancers

 

Optical Object Recognition

This simple example demonstates how easily object regognition and image processing applications can be implemented in Inlab-Scheme. Given is the following input bitmap, an excerpt of a high quality scan at a resolution of 300DPI: 

The code below looks for the following search pattern, an "e": 

 

This is the Inlab-Scheme source that analyzes each object in the input bitmap returning the number of actually found matching objects. The number of found objects is displayed and a output bitmap is generated that contains the objects that match the search criteria (of being at least 85% equal in the sense of "bitmap-equality" after resizing to 100x100) unchanged and all other objects in grey: 

 #!/usr/local/bin/scheme  

 (define cbitmap (bitmap-readxbm "pattern.xbm")) ;; pattern to search   
 (define bitmap (bitmap-readxbm "input.xbm"))    ;; input to analyze  
 (define objects (bitmap-explode bitmap))        ;; explode input  
 (define mcount 0)                               ;; number of matching objects   
 (define object-list '())                        ;; initialize list of objects   

 (writeln   
   (length objects)   
   " objects in input.xbm")  

 (for-each (lambda (object)   
   (define   
     sobject   
     (bitmap-scale-absolute object 100 100))  
   (if (> (bitmap-equality sobject cbitmap) 0.85)  
       (begin  
	 (set! mcount (+ mcount 1))  
	 (set! object-list   
	       (cons object object-list)))  
       (begin  
	 (bitmap-grey! object)   
	 (set! object-list   
	       (cons object object-list)))  
   )) objects)  

 (writeln mcount " matching objects found")  

 ;; generate output-bitmap and write it to output.xbm  

 (bitmap-writexbm   
   (bitmap-implode object-list   
		   (bitmap-height bitmap)   
		   (bitmap-width bitmap))   
		   "output.xbm")  

 (exit)  
   

A run of the program leads to the following output: 

57 objects in input.xbm
7 matching objects found

output.xbm looks now like the following and finally indicates the found objects in black: 

 

The running time is 1.1 seconds on a Pentium90 running FreeBSD 2.1.5 including initialization of Inlab-Scheme which takes about 0.2 seconds on this platform (A pentium pro 200 running FreeBSD 2.1.5 needs about 0.44 seconds including 0.05 seconds to initialize).


Copyright © 1991-2016,2017 by Inlab Networks GmbH, All Rights Reserved - Impressum - Widerrufsrecht - Sitemap - Internal