Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As many will know, images of all US censuses going back to 1790 are available online Unfortunately the quality of the images is very poor in places and, as far as I know, there are no free processed versions of them available. If you take an example like the following from the 1920 census, what would be a good method to extract relatively clean images of the handwritten text from the background image and noise?

The original pdf for the page is at as I don't have the reputation points to post it here yet (can someone with more rep upload it?).

share|improve this question
this may also prove useful… – andrew Apr 20 '15 at 17:57

I couldn't open your pdf (antivirus said it was suspicious) so i downloaded an image myself, I don't know if its the right one, but its also from a 1920 census

You could perform image dilation on the document until the text is gone. You can do multiple passes if needed. I just did one. We know dilation will make shrink the black sections (or the text) this essentially gives us just the background.

We then remove the background from the image. This can be tricky depending on the language (I used matlab, and had to make sure to keep the right range and units for the image to display properly) then you have a cleaner image. You should be able to run a ocr engine on the result

enter image description here

and here is a zoomed in section just so you can see the text quality doesn't degrade much with this operation

zoomed pic

and of course the code. As I said it is done in matlab but openCv(in many languages), python, or just about any other image library will be able to perform a similar operation

im = rgb2gray(color_im);
bg = imdilate(im,strel('disk',3));
%we do a complement becasue the bg subtraction makes the text white and 
%the background black. so we invert it
clean = imcomplement(abs(bg-im));

subplot(1,3,1); imshow(im); title('original')
subplot(1,3,2); imshow(bg); title('after imdilate with 3 pixel circle')
subplot(1,3,3); imshow(clean); title('original minus background')

and here is the image I used. Its the first page of the 1920 census

enter image description here


I forgot you said it was handwritten images. so I got another sample, same exact code, new image

enter image description here enter image description here

notice the detail even in very dark obscured places, as the zoomed in view shows. You would need to run some other filters, but removing the main background noise is accomplished using dilation

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.