An exercise in finding the text areas in the image of stamps using: thresholding, hit-or-miss morphological filtering, and dilation. This formula page is set up to find most of the large-font text on the stamps. Note that before executing these steps, you need to load and run, from the Python window, the following program: MorphologicalOperations.py. Once that program has been run, its definitions are available here in the Formula Page. Add additional formula bars that find the small text of the Bicentennial stamp. (Exercise created by S. Tanimoto, Oct. 10, 2010) BEGIN FORMULA BARS 1#|#Stamps#|##|#*,*,#|#@server:tanimoto:Stamps-aligned-reduced.jpg#|#c#|#Original image#|#100,100 2#|#Thresholded, per RGB component#|#Size(1)#|#1,*,#|#if s1(x,y) < 125 then 255 else 0#|#c#|#Thresholding #|#250,100 3#|#Structuring element for Hit-Or-Miss transform (created using Python)#|#(4,3)#|#*,*#|#!array_to_monochrome_pixelmath_image([[2,1,1,2],[0,1,1,0],[2,1,1,2]], 3)#|#c#|#Rectangular structuring element.#|#100, 500 4#|#Hit-or-miss result (vertical stroke detection)#|#Size(1)#|#2,*,#|#!hit_or_miss(2,3,4) # Call a user-defined Python function#|#c#|#Result of H-O-M#|#400,100 5#|#Where did H-O-M respond in all color components?#|#Size(1)#|#4,*#|#if Red1(x,y)=255 and Green1(x,y)=255 and Blue1(x,y)=255 then 255 else 0#|#c#|#Show white pixels only#|#100, 500 6#|#Structuring element for dilation#|#(1,10)#|#*,*#|#1#|#c#|#vertical bar struct. elt.#|# 7#|#Dilated vertically#|#Size(1)#|#5,*#|#!dilate(5,6,7)#|#c#|#fill in the general area around text#|#400,400 8#|#Structuring element for dilation#|#(30,1)#|#*,*#|#1#|#c#|#horiz. bar struct. elt.#|# 9#|#Dilated horizontally, too#|#Size(1)#|#7,*#|#!dilate(7,8,9)#|#c#|#fill in the general area around text#|#400,400 10#|#Comparison#|#Size(1)#|#1,9#|#0.5*s1(x,y)+0.3*s2(x,y)#|#c#|#Comparison#|#