 Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12892 Members
Join this group to post and comment. Nusc • Apr 12, 2009

# Wavelet's CAPTCHA

Hey guys I'm trying to denoise some images using the following script.
It was originally in Mathematica 5.2 and I'm trying to convert it to Mathematica 7.0 but so far I have been unsuccessful.
I was wondering if anyone here has any idea how to help.

I will only give one of the modules to see if it helps:

DiscreteWavelets is a package from this site:

University of St. Thomas :: Wavelets Webpage

<< DiscreteWavelets`DiscreteWavelets`

SetDelayed::write: Tag Entropy in Entropy[v_] is Protected. >>

BreakIntoChars[img_] :=
Module[{a, i, j, l, p, q, lets, r, c, mins, numchar, edge, vedge,
vmins, newimg}, {r, c} = Dimensions;
newimg =
Join[ConstantArray[0, {r, 1}] + 255, img,
ConstantArray[0, {r, 1}] + 255];
newimg =
Join[ConstantArray[0, {1, c}] + 255, img,
ConstantArray[0, {1, c}] + 255, 2];(*
Gets dimensions and pads two rows and two columns onto the image. *)
\

mins = {}; (* Sets up needed lists. *)
vmins = {};
edge = {};
vedge = {};
lets = {};

For[i = 1, i < c, i++,(* for 1 *)

a = Min[Take[newimg, All, {i, i}]]; (*
Measures the minimum value of the column and notes in a list \
where there is white space and where there is black lettering. *)

If[a < 10,
mins = Append[mins, {0}];,
mins = Append[mins, {255}];];];
mins = Flatten[mins]; (*
Removes any extra brackets in the list. *)

For[j = 1, j < c - 1, j++,
If[mins[[j + 1]] - mins[[j]] != 0 &&
mins[[j + 1]] == mins[[j + 2]], (* for 2 *)

edge = Append[edge, {j}]; (* Picks out edges,
where black lettering ends and white space begins,
or vice versa. *)
]; (* end if 2 *)
]; (* end for 1 *)

p = Length[edge];
edge = Flatten[edge]; (*
Stores length and takes out extra brackets. *)

For[k = 1, k <= p/2, k++,
lets =
Append[lets,
Take[newimg, All, {edge[[2 k - 1]], edge[[2 k]]}]]; (*
Cuts vertically based off the previously generated list of where \
there are letters. *)
]; (* end for *)

lets = CutH /@ lets; (* Application of the Horizontal Cut module,
takes off any extra white space aboev and below the letter. *)

lets = PadChar /@ lets; (* Application the Padding module,
artificially making all images 68 by 72. *)
Return[lets] (*
gives back a list of all the cut and padded letters *)
];(* end \
module *)

abcs = 1./3*
Total[ImageRead[
"/Users/CAPTCHA/alphabet2.\
bmp", PowersOfTwo -> 3, GrayScale -> True]];
alpha = BreakIntoChars[abcs];

Your help is greatly appreciated.

Share this content on your social channels -